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

datatable pagination problem

Expand Messages
  • gpaslanis
    Hello, I m having problems getting the paginator to display the next set of pages. I have 21 total records with 10 per page, but always get (1 of 1)
    Message 1 of 1 , Jul 30, 2008
    View Source
    • 0 Attachment
      Hello, I'm having problems getting the paginator to display the next
      set of pages. I have 21 total records with 10 per page, but always
      get "(1 of 1) < prev 1 - 10 next >". Either my returned dataset is
      wrong or metaFields not found? Any help much appreciated!!!

      {"ResultSet":{"Result":[
      {"RowId":"1","Key":"BG","Data":"Bag","Desc":"","Parms":"","url":"#"},
      {"RowId":"2","Key":"BK","Data":"Bulk","Desc":"","Parms":"","url":"#"}
      ,
      {"RowId":"3","Key":"BT","Data":"Bottle","Desc":"","Parms":"","url":"#
      "},
      {"RowId":"4","Key":"BX","Data":"Box","Desc":"","Parms":"","url":"#"},
      {"RowId":"5","Key":"CN","Data":"Can","Desc":"","Parms":"","url":"#"},
      {"RowId":"6","Key":"CR","Data":"Carton","Desc":"","Parms":"","url":"#
      "},
      {"RowId":"7","Key":"CS","Data":"Case","Desc":"","Parms":"","url":"#"}
      ,
      {"RowId":"8","Key":"DM","Data":"Drum","Desc":"","Parms":"","url":"#"}
      ,
      {"RowId":"9","Key":"DZ","Data":"Dozen","Desc":"","Parms":"","url":"#"
      },
      {"RowId":"10","Key":"EA","Data":"Each","Desc":"","Parms":"","url":"#"
      },
      ],
      "totRows":21,
      "rowsPerPage":10,
      "startRow":0}}

      YAHOO.util.Event.onDOMReady(function() {
      var DataSource = YAHOO.util.DataSource,
      DataTable = YAHOO.widget.DataTable,
      Paginator = YAHOO.widget.Paginator,
      oElement = document.getElementById(ddlACM1Name);

      YAHOO.example.XHR_JSON = new function() {
      this.myDataSource = null;
      this.myDataTable = null;
      this.buildQueryString = function(state,dt){
      return "group=" + oElement.options[oElement.selectedIndex].value +
      "&type=" + typACM + "&startRow=" + state.pagination.recordOffset +
      "&results=" + state.pagination.rowsPerPage;
      };
      this.formatUrl = function(elCell, oRecord, oColumn, sData) {
      elCell.innerHTML = "<a href='" + oRecord.getData("url") + "'
      target='_blank'>" + sData + "</a>";
      };
      var myColumnDefs = [
      {key: "RowId",label: "Id",formatter: DataTable.formatNumber},
      {key: "Key",sortable: true,formatter: this.formatUrl},
      {key: "Data"},
      {key: "Desc"},
      {key: "Parms"}
      ];
      this.myDataSource = new DataSource("../admin/acd.ashx?");
      this.myDataSource.responseType = DataSource.TYPE_JSON;
      this.myDataSource.connMethodPost = true;
      this.myDataSource.responseSchema = {
      resultsList: "ResultSet.Result",
      metaFields: {
      paginationRowsPerPage:"rowsPerPage",
      paginationRecordOffset:"startRow",
      totalRecords:"totRows"},
      fields:
      [{key:"RowId",parser:DataSource.parseNumber},"Key","Data","Desc","Par
      ms","url"]
      };
      var myConfigs = {
      initialRequest: "group=UOM&type=" + typACM,
      generateRequest: this.buildQueryString,
      paginationEventHandler: DataTable.handleDataSourcePagination,
      paginator: new Paginator({
      rowsPerPage: 10,
      containers: ['paging'],
      template: "<strong>{CurrentPageReport}</strong> {PreviousPageLink}
      {PageLinks} {NextPageLink} {RowsPerPageDropdown}",
      //pageLinks: Paginator.VALUE_UNLIMITED,
      pageLinks: 5,
      rowsPerPageOptions: [10, 25, 50],
      pageLabelBuilder: function(page, paginator) {
      var recs = paginator.getPageRecords(page);
      return (recs[0] + 1) + ' - ' + (recs[1] + 1);
      }
      })
      };
      this.myDataTable = new DataTable("dt", myColumnDefs,
      this.myDataSource, myConfigs);
      };
      });
    Your message has been successfully submitted and would be delivered to recipients shortly.