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

Re: updating datatable and paginator

Expand Messages
  • harshanagesh
    Thanks Luke. That was helpful and it works ! ... table ?
    Message 1 of 3 , Sep 3, 2008
    • 0 Attachment
      Thanks Luke. That was helpful and it works !

      --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@...> wrote:
      >
      > --- In ydn-javascript@yahoogroups.com, "harshanagesh"
      > <harshanagesh@> wrote:
      > >
      > > Hi,
      > >
      > > I have a datatable in a page and I want to update it with a
      > > different datasource. I was able to do it after reading Satyam's
      > > articles. Something like
      > >
      > > var dataSource = myDataTable.getDataSource();
      > > dataSource.liveData = dataUrl;
      > > dataSource.sendRequest('', myDataTable.onDataReturnInitializeTable,
      > > myDataTable);
      > >
      > > However, this does not update the paginator display. If suppose
      > > initially the table had 10 pages with 25 rows per page and now after
      > > update the table only has 3 pages to be shown, the paginator should
      > > not show links for all the 10 pages. Can anybody please let me know
      > > how do I update the paginator to be in sync with the data in the
      table ?
      > > Also, I would like to reset the position of the paginator to the first
      > > page after loading the new data. Currently if I am on page 6 and then
      > > update the table's data, after the update, I will see a result such as
      > > "no records" as the table has data only for the first 3 pages and I
      > > still in the 6th page of the previous display.
      > >
      > > Thanks
      > > Harsha
      > >
      >
      > If you can, include a totalRecords meta field in the server response
      > and point to it your DataSource config (shown in a few examples).
      >
      > If you can't do that, reset the Paginator's totalRecords by hand when
      > you update the liveData or in the first request to the DataSource with
      > the new liveData.
      > myDataSource.liveData = new_uri;
      > myDataTable.get('paginator').set('totalRecords',0);
      >
      > OR
      > myDataSource.liveData = new_uri;
      > myDataSource.sendRequest(query,{
      > success : function (req,res,payload) {
      > this.get('paginator').set('totalRecords',0);
      > this.onDataReturnSetRows(req,res,payload);
      > },
      > scope : myDataTable
      > });
      >
      > DataTable's response handling methods (onDataReturnSetRows etc) are
      > set up to *increase* the Paginator's totalRecords if needed, but not
      > to decrease it. This is to handle cases where the server reports that
      > is has more records than it has delivered--the Paginator should
      > indicate the number of pages appropriate for the reported totalRecords.
      >
      > Hope this helps,
      > Luke
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.