PDA

View Full Version : Ext.data.Store not loading all returned records



hallikpapa
12 Aug 2010, 11:27 AM
I am using a livegrid plugin, and for some reason the max amount of records it will load in is 133. I am returning 300 records each time; (verified in firebug; totalCount & version properties being returned too), but when I breakpoint in the load event, I see there is only 133 records in the store.

So what I need to know is there some way I can setup this extended Ext.data.Store class to catch the data as soon as it comes back, so I can use firebug to step through the code and find out why more than 1/2 my records aren't making it into the Store?

Here is the constructor for the store. Looking for debug ideas to catch the data as it's being loaded into the store, or other clues.



Ext.ux.grid.livegrid.Store = function(config) {

config = config || {};

// remoteSort will always be set to true.
config.remoteSort = true;

// we will intercept the autoLoad property and set it to false so we do not
// load any contents of the store before the View has not fully initialized
// itself. if autoLoad was set to true, the Ext.ux.grid.livegrid.GridPanel
// will take care of loading the store once it has been rendered
this._autoLoad = config.autoLoad ? true : false;
config.autoLoad = false;

this.addEvents(
/**
* @event bulkremove
* Fires when a bulk remove operation was finished.
* @param {Ext.ux.BufferedGridStore} this
* @param {Array} An array with the records that have been removed.
* The values for each array index are
* record - the record that was removed
* index - the index of the removed record in the store
*/
'bulkremove',
/**
* @event versionchange
* Fires when the version property has changed.
* @param {Ext.ux.BufferedGridStore} this
* @param {String} oldValue
* @param {String} newValue
*/
'versionchange',
/**
* @event beforeselectionsload
* Fires before the store sends a request for ranges of records to
* the server.
* @param {Ext.ux.BufferedGridStore} this
* @param {Array} ranges
*/
'beforeselectionsload',
/**
* @event selectionsload
* Fires when selections have been loaded.
* @param {Ext.ux.BufferedGridStore} this
* @param {Array} records An array containing the loaded records from
* the server.
* @param {Array} ranges An array containing the ranges of indexes this
* records may represent.
*/
'selectionsload'
);

Ext.ux.grid.livegrid.Store.superclass.constructor.call(this, config);

this.totalLength = 0;


/**
* The array represents the range of rows available in the buffer absolute to
* the indexes of the data model. Initialized with [-1, -1] which tells that no
* records are currrently buffered
* @param {Array}
*/
this.bufferRange = [-1, -1];

this.on('clear', function (){
this.bufferRange = [-1, -1];
}, this);

if(this.url && !this.selectionsProxy){
this.selectionsProxy = new Ext.data.HttpProxy({url: this.url});
}

};


And here is my setup, just incase someone wants to see it.



Ext.apply(this, {
title : 'Test List',
enableDragDrop : false,
cm : new Ext.grid.ColumnModel([
//this.expander,
{header: "ID", width: 10, hidden: true, sortable: true, dataIndex: 'id'},
{header: "Name", width: 160, sortable: true, dataIndex: 'name'},
{header: "Sub Domain", width: 160, sortable: true, dataIndex: 'sub_domain', renderer: this.targetPosition},
{header: "Category", width: 100, sortable: true, dataIndex: 'cat'},
{header: "Sub Category", width: 100, sortable: true, dataIndex: 'sub_cat'},
{header: "Volume", width: 100, sortable: true, dataIndex: 'volume'},
{header: "CTR %", width: 100, sortable: true, dataIndex: 'ctr'}
]),
loadMask : true,
height : 400,
store : new Ext.ux.grid.livegrid.Store({
autoLoad : false,
url : 'index.php/research/getrecords',
baseParams: {client_id : this.clientId},
bufferSize : 300,
reader : new Ext.ux.grid.livegrid.JsonReader({
root : 'data',
versionProperty : 'version',
totalProperty : 'totalCount',
idProperty : 'id'
}, [ {
name : 'id', sortType : 'int'
},{
name : 'name', sortType : 'string'
},{
name : 'client', sortType : 'string'
},{
name : 'sub_domain', sortType : 'string'
},{
name : 'cat_id', sortType : 'int'
},{
name : 'cat'
},{
name : 'sub_cat_id', sortType : 'int'
},{
name : 'sub_cat', sortType : 'string'
},{
name : 'volume', type : 'int'
},{
name : 'ctr', type : 'float'
},{
name : 'competitor', type : 'int'
},{
name : 'position', type : 'string'
}]),
sortInfo : {field: 'volume', direction: 'DESC'}
}),
selModel : new Ext.ux.grid.livegrid.RowSelectionModel(),
//plugins : [this.expander,this.filters],
view : this.liveView,
bbar : new Ext.ux.grid.livegrid.Toolbar({
view : this.liveView,
displayInfo : true
})
});

markjlyon
17 Aug 2010, 12:02 PM
I don't know if this will help you, but I encountered a similar issue and had to take two steps to resolve it.

1. I removed all \r\n control characters from the results.
2. I made sure that all my Json elements surround by quotations used ONLY the double quote character, NOT the single quote character. So this name: 'position', type: 'string' because name: "position", type: "string".

Why these actions helped I have no idea, but they did. Hopefully this will help you too.

Condor
18 Aug 2010, 3:07 AM
Check if your server is returning valid JSON (e.g. using jslint.com)

Carlos.D
15 Mar 2012, 7:31 AM
Hi,

I've got the same problems, the server send 3 record but my application receive 2, did you find a solution ? It's the "null" field causing a problem ?

This is the server response



0: {trip_id:18, name:circuit 3, user_id:1, type:A, link_id:null, app_id:null, list_order:null}
1: {trip_id:16, name:test1, user_id:1, type:A, link_id:22, app_id:8, list_order:0}
2: {trip_id:17, name:test, user_id:1, type:A, link_id:15, app_id:8, list_order:2}



This is my Model :


Ext.define('Holo.model.TripLink', {
extend: 'Ext.data.Model',
idProperty:'trip_id',

fields: [
{
name: "trip_id",
type: "int"
},
{
name: "name",
type: "String"
},
{
name: "user_id",
type: "String"
},
{
name: "type",
type: "String"
},
{
name: "link_id",
defaultValue: null
//type: "int"
},
{
name: "app_id",
defaultValue: null
//type: "int"
},
{
name: "list_order",
defaultValue: null
//type: "int"
}
],



proxy: {
type: 'ajax',
api: {
read: 'database/customRequest.php?ACTION=TRIPLISTLINK',
},

reader: {
type: 'json',
root: 'data'
}
}
});