Loading ...
Sorry, an error occurred while loading the content.

Links in a DataTable

Expand Messages
  • ter31024
    Hello, I m still fairly new at YUI and am having trouble getting links configured in a DataTable. I have added the YAHOO.widget.DataTable.formatLink method
    Message 1 of 11 , Sep 1, 2007
    • 0 Attachment
      Hello,

      I'm still fairly new at YUI and am having trouble getting links
      configured in a DataTable. I have added the
      'YAHOO.widget.DataTable.formatLink' method as a parameter to my column
      definitions and that succeeds in making the cell data equal to the
      HREF. However, what I would like to do is append an 'html' extension
      to this. I.e. the cell data would say "servers" but it would link to
      "servers.html"

      It seems the only way to do this is to override the formatLink method
      and I'm not having much luck with that. Is there an easier way to do
      this?

      Any guidance in the right direction would be appreciated.
      Tom
    • Satyam
      In the DataSource, you could do: responseSchema.fields = [ ... , {key: myLink ,parser:function(link) {return link + .html }}, ... ] or otherwise you could
      Message 2 of 11 , Sep 1, 2007
      • 0 Attachment
        In the DataSource, you could do:

        responseSchema.fields = [ ... , {key:'myLink',parser:function(link) {return
        link + '.html'}}, ... ]

        or otherwise you could either redefined the formatLink method or define your
        own separate function based on formatLink and assign it to formatter.

        Satyam

        ----- Original Message -----
        From: "ter31024" <ter@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Saturday, September 01, 2007 9:34 PM
        Subject: [ydn-javascript] Links in a DataTable


        > Hello,
        >
        > I'm still fairly new at YUI and am having trouble getting links
        > configured in a DataTable. I have added the
        > 'YAHOO.widget.DataTable.formatLink' method as a parameter to my column
        > definitions and that succeeds in making the cell data equal to the
        > HREF. However, what I would like to do is append an 'html' extension
        > to this. I.e. the cell data would say "servers" but it would link to
        > "servers.html"
        >
        > It seems the only way to do this is to override the formatLink method
        > and I'm not having much luck with that. Is there an easier way to do
        > this?
        >
        > Any guidance in the right direction would be appreciated.
        > Tom
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.484 / Virus Database: 269.13.1/982 - Release Date: 31/08/2007
        > 17:21
        >
        >
      • ter31024
        Hello, Thanks for the assistance. I ve decided that it d make the most sense to simply override the formatLink formatter in this instance. Unfortunately, I m
        Message 3 of 11 , Sep 4, 2007
        • 0 Attachment
          Hello,

          Thanks for the assistance. I've decided that it'd make the most sense
          to simply override the formatLink formatter in this instance.
          Unfortunately, I'm not having much luck doing that either. Here is
          what I have...

          ==========================================

          YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
          el.InnerHTML = '<a href=" + oData + '.html">' + oData + '</a>';
          }

          var myColumnDefs = [{
          key: 'A_HOST_HOSTNAME',
          sortable: true,
          formatter: YAHOO.widget.DataTable.formatLink
          }];

          ==========================================

          So, for example if the A_HOST_HOSTNAME key is "server1" a link will
          automatically be generated as http://server/server1. What I'd like to
          do is change that link to server1.html.

          The above code doesn't do that though, it generates an error:

          'missing ; before statement'
          YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {\n

          I just don't get it :-( ... If I remove the override, the error goes
          away. There must be an easier way to simply generate a link in a
          datatable. Any help at all would be greatly appreciated.

          Thanks,
          Tom
        • Satyam
          You override function has a quote missing right after href= . That accounts for the error, which is somewhat missleading because the compiler is quite
          Message 4 of 11 , Sep 4, 2007
          • 0 Attachment
            You override function has a quote missing right after href=". That accounts
            for the error, which is somewhat missleading because the compiler is quite
            cunfused reading text for code and vice versa.

            Those errors are easy to catch if you use some IDE or an editor with color
            coding. I personally use Notepad++
            (http://notepad-plus.sourceforge.net/uk/site.htm) and I've read good
            comments in this list about Aptana as an IDE. Both are free.

            Satyam

            ----- Original Message -----
            From: "ter31024" <ter@...>
            To: <ydn-javascript@yahoogroups.com>
            Sent: Tuesday, September 04, 2007 5:13 PM
            Subject: [ydn-javascript] Re: Links in a DataTable


            > Hello,
            >
            > Thanks for the assistance. I've decided that it'd make the most sense
            > to simply override the formatLink formatter in this instance.
            > Unfortunately, I'm not having much luck doing that either. Here is
            > what I have...
            >
            > ==========================================
            >
            > YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
            > el.InnerHTML = '<a href=" + oData + '.html">' + oData + '</a>';
            > }
            >
            > var myColumnDefs = [{
            > key: 'A_HOST_HOSTNAME',
            > sortable: true,
            > formatter: YAHOO.widget.DataTable.formatLink
            > }];
            >
            > ==========================================
            >
            > So, for example if the A_HOST_HOSTNAME key is "server1" a link will
            > automatically be generated as http://server/server1. What I'd like to
            > do is change that link to server1.html.
            >
            > The above code doesn't do that though, it generates an error:
            >
            > 'missing ; before statement'
            > YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {\n
            >
            > I just don't get it :-( ... If I remove the override, the error goes
            > away. There must be an easier way to simply generate a link in a
            > datatable. Any help at all would be greatly appreciated.
            >
            > Thanks,
            > Tom
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            > --
            > No virus found in this incoming message.
            > Checked by AVG Free Edition.
            > Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
            > 9:31
            >
            >
          • ter31024
            Thanks for the help Satyam, it is really appreciated. I ve corrected the missing quote, also corrected el.InnerHTML to el.innerHTML and am still getting
            Message 5 of 11 , Sep 4, 2007
            • 0 Attachment
              Thanks for the help Satyam, it is really appreciated.

              I've corrected the missing quote, also corrected 'el.InnerHTML' to
              'el.innerHTML' and am still getting the same error. The odd thing is,
              if I do something like this:

              YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
              el.innerHTML = "Hello World";
              }

              The error still shows. Above this override is just the usual
              'YAHOO.util.Event.addListener(window, "load", function() {' line...
              and if I comment out the overload entirely, the error goes away.

              I'm wondering if I am doing something wrong with trying to overload
              this function. I am trying to pass 'el' based on what I read in the
              Yahoo API under formatLink's arguments. Checking the example of an
              overload,
              http://developer.yahoo.com/yui/examples/datatable/dt_formatting.html,
              the overloaded formatter is formatMail and that accepts an 'elCell' as
              the first argument. In addition, it uses
              YAHOO.widget.Column.formatEmail which I think is just a shortcut. I'm
              lost. :-(
            • Satyam
              Sorry, not paying enough attention, the function is missing YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn, oData) { el.innerHTML =
              Message 6 of 11 , Sep 4, 2007
              • 0 Attachment
                Sorry, not paying enough attention, the 'function' is missing

                YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn, oData) {
                el.innerHTML = "Hello World";
                };


                ----- Original Message -----
                From: "ter31024" <ter@...>
                To: <ydn-javascript@yahoogroups.com>
                Sent: Tuesday, September 04, 2007 7:25 PM
                Subject: [ydn-javascript] Re: Links in a DataTable


                > Thanks for the help Satyam, it is really appreciated.
                >
                > I've corrected the missing quote, also corrected 'el.InnerHTML' to
                > 'el.innerHTML' and am still getting the same error. The odd thing is,
                > if I do something like this:
                >
                > YAHOO.widget.DataTable.formatLink(el, oRecord, oColumn, oData) {
                > el.innerHTML = "Hello World";
                > }
                >
                > The error still shows. Above this override is just the usual
                > 'YAHOO.util.Event.addListener(window, "load", function() {' line...
                > and if I comment out the overload entirely, the error goes away.
                >
                > I'm wondering if I am doing something wrong with trying to overload
                > this function. I am trying to pass 'el' based on what I read in the
                > Yahoo API under formatLink's arguments. Checking the example of an
                > overload,
                > http://developer.yahoo.com/yui/examples/datatable/dt_formatting.html,
                > the overloaded formatter is formatMail and that accepts an 'elCell' as
                > the first argument. In addition, it uses
                > YAHOO.widget.Column.formatEmail which I think is just a shortcut. I'm
                > lost. :-(
                >
                >
                >
                >
                >
                > Yahoo! Groups Links
                >
                >
                >
                >
                >
                > --
                > No virus found in this incoming message.
                > Checked by AVG Free Edition.
                > Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
                > 9:31
                >
                >
              • ter31024
                Satyam, you rock! Thanks so much. All is working great now.
                Message 7 of 11 , Sep 4, 2007
                • 0 Attachment
                  Satyam, you rock!

                  Thanks so much. All is working great now.
                • ter31024
                  Ooof, I celebrated too soon. Now this is bizarre. Everything is working great in Firefox, however, if you load the page in IE7 the links are completely gone
                  Message 8 of 11 , Sep 4, 2007
                  • 0 Attachment
                    Ooof, I celebrated too soon. Now this is bizarre. Everything is
                    working great in Firefox, however, if you load the page in IE7 the
                    links are completely gone and the cells are empty!

                    What I have is...

                    YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn,
                    oData) {
                    el.innerHTML = '<a href="/views/' + oData + '.html>' + oData + '</a>';
                    };

                    This overrides the default formatLink perfectly and gives me want I
                    want. Works like a charm in Firefox, however, now the links just show
                    up blank in IE6 and IE7. Not sure if it is a YUI bug or something I
                    need to add/am doing wrong.

                    Thanks,
                    Tom

                    --- In ydn-javascript@yahoogroups.com, "ter31024" <ter@...> wrote:
                    >
                    > Satyam, you rock!
                    >
                    > Thanks so much. All is working great now.
                    >
                  • Satyam
                    You are missing a double qute after .html ... From: ter31024 To: Sent: Tuesday, September 04, 2007 8:46
                    Message 9 of 11 , Sep 4, 2007
                    • 0 Attachment
                      You are missing a double qute after '.html">


                      ----- Original Message -----
                      From: "ter31024" <ter@...>
                      To: <ydn-javascript@yahoogroups.com>
                      Sent: Tuesday, September 04, 2007 8:46 PM
                      Subject: [ydn-javascript] Re: Links in a DataTable


                      > Ooof, I celebrated too soon. Now this is bizarre. Everything is
                      > working great in Firefox, however, if you load the page in IE7 the
                      > links are completely gone and the cells are empty!
                      >
                      > What I have is...
                      >
                      > YAHOO.widget.DataTable.formatLink = function (el, oRecord, oColumn,
                      > oData) {
                      > el.innerHTML = '<a href="/views/' + oData + '.html>' + oData + '</a>';
                      > };
                      >
                      > This overrides the default formatLink perfectly and gives me want I
                      > want. Works like a charm in Firefox, however, now the links just show
                      > up blank in IE6 and IE7. Not sure if it is a YUI bug or something I
                      > need to add/am doing wrong.
                      >
                      > Thanks,
                      > Tom
                      >
                      > --- In ydn-javascript@yahoogroups.com, "ter31024" <ter@...> wrote:
                      >>
                      >> Satyam, you rock!
                      >>
                      >> Thanks so much. All is working great now.
                      >>
                      >
                      >
                      >
                      >
                      >
                      > Yahoo! Groups Links
                      >
                      >
                      >
                      >
                      >
                      > --
                      > No virus found in this incoming message.
                      > Checked by AVG Free Edition.
                      > Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
                      > 9:31
                      >
                      >
                    • sudermatt
                      OK, I have another question related to this.... If I have a column in the my data that contains an ID value, and another column that contains a label. UserID
                      Message 10 of 11 , Sep 4, 2007
                      • 0 Attachment
                        OK, I have another question related to this....

                        If I have a column in the my data that contains an ID value, and
                        another column that contains a label.

                        UserID
                        UserName

                        How can I set up the formatter function so that the UserName column
                        displays the UserName as a link to a page sending the UserID

                        viewUser.asp?UserID=xxxxx
                      • Satyam
                        var myFormatter = function(el, oRecord, oColumn, oData) { el.innerHTML = + oData + ; };
                        Message 11 of 11 , Sep 4, 2007
                        • 0 Attachment
                          var myFormatter = function(el, oRecord, oColumn, oData) {

                          el.innerHTML = '<a href="page.php?userID=' + oRecord.getData('UserID') +
                          '">' + oData + '</a>';

                          };

                          You assign it as a formatter for the UserName column so the UserName comes
                          in the oData argument. The UserID you pick from the record.

                          Satyam

                          ----- Original Message -----
                          From: "sudermatt" <sudermatt@...>
                          To: <ydn-javascript@yahoogroups.com>
                          Sent: Wednesday, September 05, 2007 6:52 AM
                          Subject: [ydn-javascript] Re: Links in a DataTable


                          > OK, I have another question related to this....
                          >
                          > If I have a column in the my data that contains an ID value, and
                          > another column that contains a label.
                          >
                          > UserID
                          > UserName
                          >
                          > How can I set up the formatter function so that the UserName column
                          > displays the UserName as a link to a page sending the UserID
                          >
                          > viewUser.asp?UserID=xxxxx
                          >
                          >
                          >
                          >
                          >
                          >
                          > Yahoo! Groups Links
                          >
                          >
                          >
                          >
                          >
                          > --
                          > No virus found in this incoming message.
                          > Checked by AVG Free Edition.
                          > Version: 7.5.485 / Virus Database: 269.13.3/986 - Release Date: 03/09/2007
                          > 9:31
                          >
                          >
                        Your message has been successfully submitted and would be delivered to recipients shortly.