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

sorting the data for the current page in server side pagination

Expand Messages
  • venkat_ee03
    I am using YUI server side pagination using JSON. Now I wanted to sort the each page separately on clicking of the table header. I know I can do the sorting
    Message 1 of 2 , Sep 1 3:17 AM
    • 0 Attachment
      I am using YUI server side pagination using JSON. Now I wanted to sort the each page separately on clicking of the table header. I know I can do the sorting for the entire data set. But sorting the data for the current page (only for the current page)is a challenge. Does any body have a suggestions?
    • y_lsmith
      ... This is an interesting problem. I can t say I understand what application this would be a natural user experience for, but here s what you ll need to do:
      Message 2 of 2 , Sep 3 10:10 PM
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "venkat_ee03" <venkat_ee03@...> wrote:
        >
        > I am using YUI server side pagination using JSON. Now I wanted to sort the each page separately on clicking of the table header. I know I can do the sorting for the entire data set. But sorting the data for the current page (only for the current page)is a challenge. Does any body have a suggestions?
        >

        This is an interesting problem. I can't say I understand what application this would be a natural user experience for, but here's what you'll need to do:
        1) Create markup to contain the Paginator(s) and the DataTable separately
        2) Instantiate a Paginator. Set the Paginator's "containers" config, pointing to the element(s) you included in the markup
        3) Subscribe to the Paginator's changeRequest event. In the callback, issue a sendRequest to your DataSource using the state.recordOffset from the state argument passed to the callback
        4) Instantiate the DataTable being sure that the dynamicData config is NOT being set (it defaults to false) and do NOT pass the Paginator in the configuration. Set whichever columns you like to be sortable.

        If you know already how many records you will be paging through, pass that in your Paginator's totalRecords config at construction. If you don't know the total number of records until the server responds, you'll need to override the DataSource's doBeforeParseData method to set the Paginator's totalRecords attribute.

        This is all pretty convoluted, but hey, you're asking for a pretty convoluted set up :)

        I put together this code, which works for me:
        http://gist.github.com/180738

        Hope this helps,
        Luke
      Your message has been successfully submitted and would be delivered to recipients shortly.