Results 1 to 2 of 2

Thread: Fix for paging error with JSON datasource

  1. #1
    Sencha User
    Join Date
    Mar 2007
    Posts
    27
    Vote Rating
    0
      0  

    Default Fix for paging error with JSON datasource

    Jack,

    While the code to extract the total rows appears in the XML datasource it does not appear to have made its way into JSON one. You may wish to consider the fix below.

    Regards,

    Gordon
    <pre>
    YAHOO.ext.grid.JSONDataModel.prototype.loadData = function(data, callback, keepExisting){
    var idField = this.schema.id;
    var fields = this.schema.fields;
    var rowData = [];
    try{
    var v=eval('data.'+this.schema.totalTag);
    if(!isNaN(v))
    {
    this.totalCount=v;
    }
    var root = eval('data.' + this.schema.root);
    for(var i = 0; i < root.length; i++){
    var node = root[i];
    var colData = [];
    colData.node = node;
    colData.id = (typeof node[idField] != 'undefined' && node[idField] !== '' ? node[idField] : String(i));
    for(var j = 0; j < fields.length; j++) {
    var val = node[fields[j]];
    if(typeof val == 'undefined'){
    val = '';
    }
    if(this.preprocessors[j]){
    val = this.preprocessors[j](val);
    }
    colData.push(val);
    }
    rowData.push(colData);
    }
    if(keepExisting !== true){
    this.removeAll();
    }
    this.addRows(rowData);
    if(typeof callback == 'function'){
    callback(this, true);
    }
    this.fireLoadEvent();
    }catch(e){
    this.fireLoadException(e, null);
    if(typeof callback == 'function'){
    callback(this, false);
    }
    }
    };
    </pre>

  2. #2
    Ext User
    Join Date
    Mar 2007
    Posts
    287
    Vote Rating
    0
      0  

    Default

    Jack's fixed that in the 0.33 beta build - set totalProperty in your JSONDataModel schema.

Similar Threads

  1. Grid paging with JSON
    By dflkid in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 14 Nov 2006, 5:46 PM
  2. Grid paging with JSON
    By dflkid in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 14 Nov 2006, 3:51 PM
  3. Grid paging with JSON
    By dflkid in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 14 Nov 2006, 2:40 PM
  4. Grid paging with JSON
    By dflkid in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 14 Nov 2006, 2:21 PM
  5. Grid paging with JSON
    By dflkid in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 14 Nov 2006, 2:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •