PDA

View Full Version : data.Store populates grid but getCount returns 0



kevin_i_smith
3 Oct 2009, 4:00 PM
My grid is properly populated from my data store but when I call getCount() it returns 0.
Since the grid fills in correctly the data store is os obviously populated by my XML reader and I know it's done asynchronously but I think I've accounted for that. (I do all the processing in response to the load event)

Any ideas? I call both getCount and getTotalCount but both return 0.

function fieldsLoaded(FieldStore) {


var grid = new Ext.grid.GridPanel({
store: FieldStore,
columns: [
{header: "name", width: 120, dataIndex: 'name', sortable: true},
{header: "label", width: 180, dataIndex: 'label', sortable: true},
],
renderTo:'example-grid',
width:540,
height:200
});

console.log(FieldStore.getCount() );
console.log(FieldStore.getTotalCount() );

};

Ext.onReady(function(){
var HttpProxy = new Ext.data.HttpProxy({url: 'Template.xml'});

var FieldStore = new Ext.data.Store({
proxy:HttpProxy,
reader: new Ext.data.XmlReader( {record: 'domain[@name=Blank 1] field'},
[{name: 'name', mapping: '@name'},{name: 'label', mapping: '@label'}] )
});
FieldStore.load();
FieldStore.on('load', fieldsLoaded(FieldStore));
});

kevin_i_smith
4 Oct 2009, 8:55 AM
I never figured out the problem but in testing, debugging and rewriting I ended up with rewritten code that is working.