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

Re: [ydn-javascript] Sorting URLs in a Datatable

Expand Messages
  • Satyam
    To sort this kind of data you should use a sort function as shown in the second code box in: http://developer.yahoo.com/yui/datatable/#advancedsort You add the
    Message 1 of 2 , Jan 31, 2008
    View Source
    • 0 Attachment
      To sort this kind of data you should use a sort function as shown in the
      second code box in:

      http://developer.yahoo.com/yui/datatable/#advancedsort

      You add the property:

      sortOptions:{sortFunction:mySortFunctino} // [SIC: I just noticed it is
      spelled wrong in the example] ;-)

      and in mySortFunction you parse use getData() to read the whole hyperlinked
      name from each reacord a and b, parse each and return the comparison of
      them, without modifying the original data.

      So, where it says:

      var compState = comp(a.getData("Column2"), b.getData("Column2"), desc);

      you would have:

      var compState = comp(myUrlParser(a.getData("Column2")),
      myUrlParser(b.getData("Column2")), desc);

      where myUrlParse would be a function that receives the full field and
      returns only the names. (JavaScript allows inner functions so it can be
      defined within mySortFunction itself)

      If you parse those links in the DataSource, what you return from the parser
      will be the only thing the DataTable will know about, the rest will be gone
      for good.

      Satyam


      ----- Original Message -----
      From: "Amy" <amykhar@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Thursday, January 31, 2008 5:15 PM
      Subject: [ydn-javascript] Sorting URLs in a Datatable


      >I am working on building a datatable from an existing html table. Each
      >cell of the table is
      > comprised of a link such as:
      >
      > <a href="http://amy.sleeplms.net/index.php?
      > module=lms&func=edit&instance=145">Guthrie</a>
      >
      > or
      >
      > <a href="http://amy.sleeplms.net/index.php?
      > module=lms&func=edit&instance=146">Hill</a>
      >
      > I need to be able to sort these, not on the 145 and 146, but on Guthrie
      > and Hill - the
      > words inside the link.
      >
      > I wrote a parser that can strip off the html and then sort by the text.
      > It works quite well.
      >
      > BUT,
      >
      > The darn DataTable is not leaving the link in the cell. It's replacing it
      > with the stripped
      > text.
      >
      > So, instead of my links, I have only the words, Guthrie, Hill, etc.
      >
      > How do I make the datatable sort the url properly but leave my links in
      > the table?
      >
      > Amy
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.516 / Virus Database: 269.19.17/1252 - Release Date:
      > 30/01/2008 20:51
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.