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

DataTable client side sorting issue.

Expand Messages
  • msapunov
    Hi! I have question about client side sorting inside DataTable. So, i have a DataTable and time to time i have to put a new data in it using initializeTable
    Message 1 of 4 , Feb 4, 2008
      Hi!
      I have question about client side sorting inside DataTable. So, i have
      a DataTable and time to time i have to put a new data in it using
      initializeTable method(could be some other methods but i find out that
      only this one is suitable for me). But, in this case i have a
      predictable glitch concerning with sorting issue. Despite of previous
      sorting, the table start to fill with data's in their turn order. So,
      how could i fill the table keeping previous sorting intact? Is the
      only option to sort new data's manually? If this question is already
      discussed fill free to point me on it :)
      Cheers.
    • Satyam
      New rows are added to the DataTable where the index says and, if none, at the end, regardless of how or whether it is sorted. The sortedBy configuration
      Message 2 of 4 , Feb 4, 2008
        New rows are added to the DataTable where the index says and, if none, at
        the end, regardless of how or whether it is sorted. The sortedBy
        configuration attribute only helps in highlighting the right column and
        keeping it highlighted when the table is refreshed, but it does not affect
        the data, existing or new. You can actually set sortedBy on unsorted data
        and the DataTable won't notice.

        You have three choices: let the user re-sort the data (highlighting the
        added rows might help the user know that it is meant to work like that).
        You can use method sortColumn to resort the data and, finally, you can do a
        binary search on the existing data and find the index of the position to
        insert it in.

        The easiest is to use sortColumn to resort the data, since all except one
        record is already sorted, it shouldn't waste much time at all.

        Right now, sortColumn only takes one argument, the column to be sorted but
        does not take whether ascending or descending. If you call sortColumn on
        the column which is currently sorted, it will reverse. Adding a direction
        argument has been requested and should be available in next version soon to
        be released.

        Satyam



        ----- Original Message -----
        From: "msapunov" <msapunov@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Monday, February 04, 2008 12:51 PM
        Subject: [ydn-javascript] DataTable client side sorting issue.


        > Hi!
        > I have question about client side sorting inside DataTable. So, i have
        > a DataTable and time to time i have to put a new data in it using
        > initializeTable method(could be some other methods but i find out that
        > only this one is suitable for me). But, in this case i have a
        > predictable glitch concerning with sorting issue. Despite of previous
        > sorting, the table start to fill with data's in their turn order. So,
        > how could i fill the table keeping previous sorting intact? Is the
        > only option to sort new data's manually? If this question is already
        > discussed fill free to point me on it :)
        > Cheers.
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date:
        > 03/02/2008 17:49
        >
        >
      • msapunov
        So, technically, i have to get the sorted column name (via myDataTable._configs.sortedBy.value.key) and apply the myDataTable.sortColumn() method twice, am i
        Message 3 of 4 , Feb 4, 2008
          So, technically, i have to get the sorted column name (via
          myDataTable._configs.sortedBy.value.key) and apply the
          myDataTable.sortColumn() method twice, am i right?

          --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
          >
          > New rows are added to the DataTable where the index says and, if
          none, at
          > the end, regardless of how or whether it is sorted. The sortedBy
          > configuration attribute only helps in highlighting the right column and
          > keeping it highlighted when the table is refreshed, but it does not
          affect
          > the data, existing or new. You can actually set sortedBy on
          unsorted data
          > and the DataTable won't notice.
          >
          > You have three choices: let the user re-sort the data (highlighting
          the
          > added rows might help the user know that it is meant to work like
          that).
          > You can use method sortColumn to resort the data and, finally, you
          can do a
          > binary search on the existing data and find the index of the
          position to
          > insert it in.
          >
          > The easiest is to use sortColumn to resort the data, since all
          except one
          > record is already sorted, it shouldn't waste much time at all.
          >
          > Right now, sortColumn only takes one argument, the column to be
          sorted but
          > does not take whether ascending or descending. If you call
          sortColumn on
          > the column which is currently sorted, it will reverse. Adding a
          direction
          > argument has been requested and should be available in next version
          soon to
          > be released.
          >
          > Satyam
          >
          >
          >
          > ----- Original Message -----
          > From: "msapunov" <msapunov@...>
          > To: <ydn-javascript@yahoogroups.com>
          > Sent: Monday, February 04, 2008 12:51 PM
          > Subject: [ydn-javascript] DataTable client side sorting issue.
          >
          >
          > > Hi!
          > > I have question about client side sorting inside DataTable. So, i have
          > > a DataTable and time to time i have to put a new data in it using
          > > initializeTable method(could be some other methods but i find out that
          > > only this one is suitable for me). But, in this case i have a
          > > predictable glitch concerning with sorting issue. Despite of previous
          > > sorting, the table start to fill with data's in their turn order. So,
          > > how could i fill the table keeping previous sorting intact? Is the
          > > only option to sort new data's manually? If this question is already
          > > discussed fill free to point me on it :)
          > > Cheers.
          > >
          > >
          > >
          > >
          > > Yahoo! Groups Links
          > >
          > >
          > >
          > >
          > >
          > > --
          > > No virus found in this incoming message.
          > > Checked by AVG Free Edition.
          > > Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date:
          > > 03/02/2008 17:49
          > >
          > >
          >
        • Satyam
          Yes and no. First, avoid anything that starts with an underscore. Those are meant to be private members, something that JavaScript does not have so the
          Message 4 of 4 , Feb 4, 2008
            Yes and no. First, avoid anything that starts with an underscore. Those
            are meant to be private members, something that JavaScript does not have so
            the underscore is a convention for the user to know that such interface is
            discouraged (support or backward compatibility for it may eventually be
            dropped). Use, instead:

            myDataTable.get('sortedBy').key // there is a set() method as well

            These methods are inherited from Element, that's why you won't find them in
            the index for DataTable.

            Second, you don't need to do it twice. sortColumn reverses the sort order
            it believes it has (it simply serves the event of clicking a column header)
            so you can first make it believe the order is the opposite of what it
            actually has by reversing the 'dir' property of sortedBy and then doing a
            single sort. You can also wait the few weeks it will take for the new
            version which should have the second argument for sortColumn.

            Otherwise, what you suggest will work.

            Satyam


            ----- Original Message -----
            From: "msapunov" <msapunov@...>
            To: <ydn-javascript@yahoogroups.com>
            Sent: Monday, February 04, 2008 2:54 PM
            Subject: [ydn-javascript] Re: DataTable client side sorting issue.


            > So, technically, i have to get the sorted column name (via
            > myDataTable._configs.sortedBy.value.key) and apply the
            > myDataTable.sortColumn() method twice, am i right?
            >
            > --- In ydn-javascript@yahoogroups.com, "Satyam" <satyam@...> wrote:
            >>
            >> New rows are added to the DataTable where the index says and, if
            > none, at
            >> the end, regardless of how or whether it is sorted. The sortedBy
            >> configuration attribute only helps in highlighting the right column and
            >> keeping it highlighted when the table is refreshed, but it does not
            > affect
            >> the data, existing or new. You can actually set sortedBy on
            > unsorted data
            >> and the DataTable won't notice.
            >>
            >> You have three choices: let the user re-sort the data (highlighting
            > the
            >> added rows might help the user know that it is meant to work like
            > that).
            >> You can use method sortColumn to resort the data and, finally, you
            > can do a
            >> binary search on the existing data and find the index of the
            > position to
            >> insert it in.
            >>
            >> The easiest is to use sortColumn to resort the data, since all
            > except one
            >> record is already sorted, it shouldn't waste much time at all.
            >>
            >> Right now, sortColumn only takes one argument, the column to be
            > sorted but
            >> does not take whether ascending or descending. If you call
            > sortColumn on
            >> the column which is currently sorted, it will reverse. Adding a
            > direction
            >> argument has been requested and should be available in next version
            > soon to
            >> be released.
            >>
            >> Satyam
            >>
            >>
            >>
            >> ----- Original Message -----
            >> From: "msapunov" <msapunov@...>
            >> To: <ydn-javascript@yahoogroups.com>
            >> Sent: Monday, February 04, 2008 12:51 PM
            >> Subject: [ydn-javascript] DataTable client side sorting issue.
            >>
            >>
            >> > Hi!
            >> > I have question about client side sorting inside DataTable. So, i have
            >> > a DataTable and time to time i have to put a new data in it using
            >> > initializeTable method(could be some other methods but i find out that
            >> > only this one is suitable for me). But, in this case i have a
            >> > predictable glitch concerning with sorting issue. Despite of previous
            >> > sorting, the table start to fill with data's in their turn order. So,
            >> > how could i fill the table keeping previous sorting intact? Is the
            >> > only option to sort new data's manually? If this question is already
            >> > discussed fill free to point me on it :)
            >> > Cheers.
            >> >
            >> >
            >> >
            >> >
            >> > Yahoo! Groups Links
            >> >
            >> >
            >> >
            >> >
            >> >
            >> > --
            >> > No virus found in this incoming message.
            >> > Checked by AVG Free Edition.
            >> > Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date:
            >> > 03/02/2008 17:49
            >> >
            >> >
            >>
            >
            >
            >
            >
            >
            > Yahoo! Groups Links
            >
            >
            >
            >
            >
            > --
            > No virus found in this incoming message.
            > Checked by AVG Free Edition.
            > Version: 7.5.516 / Virus Database: 269.19.19/1257 - Release Date:
            > 03/02/2008 17:49
            >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.