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

Re: DataTable with Paginator: allRecords update

Expand Messages
  • kduncklee
    ... Bug filed: http://yuilibrary.com/projects/yui2/ticket/2527763 Thanks, Kevin
    Message 1 of 5 , Mar 3, 2009
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@...> wrote:
      >
      > --- In ydn-javascript@yahoogroups.com, "kduncklee"
      > <ydn-javascript.kevin@> wrote:
      > >
      > > --- In ydn-javascript@yahoogroups.com, "Lucas Smith" <lsmith@> wrote:
      > > >
      > > > --- In ydn-javascript@yahoogroups.com, "kduncklee"
      > > > <ydn-javascript.kevin@> wrote:
      > > > >
      > > > > In DataTable's render(), it looks at the paginator to see which
      > > > > records to display:
      > > > > if(oPaginator) {
      > > > > allRecords = this._oRecordSet.getRecords(
      > > > > oPaginator.getStartIndex(),
      > > > > oPaginator.getRowsPerPage());
      > > > > }
      > > > >
      > > > > However, if the number of records on the server decreased and we are
      > > > > looking at the last page, this will return an incorrect result. We
      > > > > will see invalid records at the end.
      > > > >
      > > > > I think the correct code would use Paginator's getPageRecords(), as
      > > > > this returns the correct number for the ending record.
      > > > >
      > > > > My code does update totalRecords:
      > > > > container.myDataTable.doBeforeLoadData = function(oRequest,
      > oResponse,
      > > > > oPayload) {
      > > > > if(oPayload != null) {
      > > > > oPayload.totalRecords = oResponse.meta.totalRecords;
      > > > > oPayload.pagination.recordOffset = oResponse.meta.start;
      > > > > if(oResponse.meta.sort != "") {
      > > > > oPayload.sortedBy = {key: oResponse.meta.sort,
      > > > > dir: oResponse.meta.dir == "asc" ?
      > > > > YAHOO.widget.DataTable.CLASS_ASC
      > > > > :
      > > > > YAHOO.widget.DataTable.CLASS_DESC};
      > > > > }
      > > > > }
      > > > > return oPayload;
      > > > > };
      > > > >
      > > > > Is there something I should be doing differently or should I file
      > > a bug?
      > > > >
      > > > > Thanks,
      > > > > Kevin
      > > > >
      > > >
      > > > Kevin,
      > > >
      > > > Which version of YUI are you using?
      > > >
      > > > Luke
      > > >
      > >
      > > I had been using 2.6.0, but still see the problem in 2.7.0.
      > >
      > > Kevin
      > >
      >
      > Kevin,
      >
      > Yep, looks like a good candidate for a bug:
      > http://yuilibrary.com/projects/yui2/newticket
      >
      > So it sounds like what you're running into is a result of DataTable's
      > onDataReturnSetRecords functionality. It applies Record data to the
      > specified indexes in the RecordSet, but operates only by overwriting
      > Records, never clearing them.
      >
      > As a workaround, try adding the following line into your
      > doBeforeLoadData method
      > this._oRecordSet.reset();
      >
      > Luke
      >

      Bug filed:
      http://yuilibrary.com/projects/yui2/ticket/2527763

      Thanks,
      Kevin
    Your message has been successfully submitted and would be delivered to recipients shortly.