views:

150

answers:

0

I have a simple table that performs a JSON request to get data. Everything worked fine until I got too many records and added a paginator.

Now, the initial request returns 52, entries, but my yui-databale displays 'no records', until I change let's say the number of items per page, then it refreshes the widget properly. Here's the code:

This is is an onloadJS...

   var columnDefs = [
      {key: "status", label:"Status", sortable:true, formatter:formatStatus, width:30},
      {key: "name", label:"Sandbox Name", sortable:true, formatter:formatSandboxName, minWidth: 150},
      {key: "game", label:"Game", sortable:true},
      {key: "platform", label:"Platform", sortable:true},
      {key: "environment", label:"Env.", sortable:true},
      {key: "id", label:"Reports", formatter:formatReports}
   ];

   dataSet = new YAHOO.util.XHRDataSource("/proxy/status/json/?proxy_id=1");
   dataSet.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;

   dataSet.responseSchema = {
                       resultsList: "results",
                       fields: ["status", "name", "environment", "platform", "game", "id"]
                    };

   var oConfigs = {
                     sortedBy: {key:"environment", dir:"asc"},
                     paginator: new YAHOO.widget.Paginator({
                     template: "Show{RowsPerPageDropdown}per page {PageLinks}", 
                     rowsPerPageOptions : [5,10,50], 
                     initialLoad: false
                   })    
   }          

   statusTable = new YAHOO.widget.DataTable("tableContainer", columnDefs, dataSet, oConfigs);


   statusTable.handleDataReturnPayload = function(request, response, payload) { 
          if (payload == undefined) {
                     payload = {};  
             }
                        payload.totalRecords = response['results'].length;
          $Y.log("handleDataReturnPayload: total records: " + payload.totalRecords);    
                        return payload; 
                    }

   statusTable.onDataReturnInitializeTable = function(request, response, payload) {
          $Y.log("onDataReturnInitializeTable" + request + response + payload);
      }

   dataTableCallback = {success: function (req, resp, crap) { 
                                 $DOM.setStyle('LoadingDiv', 'display', 'none');
            $Y.log("success, dataTableCallback");

                             }, 
                   failure: function(o) { 
                                 $DOM.setStyle('LoadingDiv', 'display', 'none');
            $Y.log("failure, dataTableCallback");
                                 showStatusWarning("Status error at " + getDateTimeStr(), "Error polling for status.<br />" + $dump(o)); 
                             }, 
                   scope: statusTable};

dataSet.setInterval(15000, "", dataTableCallback);