PDA

View Full Version : XML Store 'load' getting invoked multiple times.



kagupta@quark.com
5 Nov 2009, 10:18 PM
I was tring to use XmlStore where store is loaded from url provided.


function getUserInfoGrid() {
var store = new Ext.data.XmlStore({
autoDestroy: true,
url: 'TestApp/getInfo.xml', // automatically configures a HttpProxy
// reader configs
record: 'record',
idPath: 'record[id]',
autoLoad : true,
fields: [
// set up the fields mapping into the xml doc
// The first needs mapping, the others are very basic
{name: 'id', mapping: 'record[id]'},
{name: 'name', mapping: 'record[name]'}
]
});
var grid = new Ext.grid.EditorGridPanel({
store: store,
columns: [{
dataIndex :"id",
hidden :true,
sortable :false
},{
header :'User Name',
dataIndex :"name",
width :210,
sortable :true
}],
autoHeight: true
});
//store.load();
store.on('load',function(){
var count = store.getTotalCount();
alert("count ="+count);
});
return grid;
}
and xml returned is


<records>
<record id="1" name="Jack">
</record>
<record id="2" name="Monica">
</record>
</records>

Issue is when i call getUserInfoGrid() function for creating grid. Store for loading is making multiple calls (3) to servlet layer and store on'load' event is getting called 3 times. How to make sure that store only makes single call to load datastore.

Thanks..

kagupta@quark.com
6 Nov 2009, 1:29 AM
Sorry my mistake same function was getting called from tabpanel activate listener.