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

Re: [ydn-javascript] DataTable numeric sort

Expand Messages
  • Satyam
    The problem you are having is because the sorting is done on the recordSet, not the formatted data. To get the recordSet data to sort correctly you have to
    Message 1 of 2 , Oct 30, 2007
    • 0 Attachment
      The problem you are having is because the sorting is done on the recordSet,
      not the formatted data. To get the recordSet data to sort correctly you
      have to have its contents of the right type. As it comes from whichever
      DataSource you took it, you have to parse it into a number, otherwise it
      will remain as a string, which is all you have in a stream of character
      data. If you go to the DataTable documentation page and search for the word
      'parseNumber', you'll see several examples on how to use it. It is an
      argument for the DataSource, since there is where the parsing is done.

      Satyam

      ----- Original Message -----
      From: "minongiit" <mino@...>
      To: <ydn-javascript@yahoogroups.com>
      Sent: Tuesday, October 30, 2007 5:21 PM
      Subject: [ydn-javascript] DataTable numeric sort


      > Hi everyone,
      > this is about "sorting a numeric type field in a datatable widget".
      >
      > I've been searching a lot about this topic, I saw older messages in
      > the mailinglist but I couldn't find a proper solution.
      >
      > I have a table defined as follows:
      >
      > var TestTable = [
      >
      >
      > {key:"TestNumber", formatter:'number', sortable:true},
      > {key:"AnotherTestNumber", formatter:'number', sortable:true},
      >
      >
      > {key:"TestString", sortable:true},
      > {key:"AnotherTestString", sortable:true}
      > ];
      >
      > How can I allow the user to properly sort the TestNumber column, so
      > that for example "9" is lower than "10" (in alphabetic order this
      > isn't true)?
      >
      > I've tried to define a custom sorting function without result.
      >
      > Please, anyone could help?
      > It's a very common problem, I believe.
      >
      > Thanks indeed! :)
      > Mino
      >
      >
      >
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      > --
      > No virus found in this incoming message.
      > Checked by AVG Free Edition.
      > Version: 7.5.503 / Virus Database: 269.15.12/1098 - Release Date:
      > 29/10/2007 9:28
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.