PDA

View Full Version : data.Store reload



duk
26 Oct 2010, 6:34 AM
I have data.store


var sDataStore = new Ext.data.Store({
id: 'sDataStore',
proxy: new Ext.data.HttpProxy({
url: 's.php',
method: 'POST'
}),
baseParams:{task: "LISTING"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[ {name: 'id', type: 'int', mapping: 'id'}])
});
I add record to table in Ext.Ajax.request.

After success response:



lastOptions = sDataStore.lastOptions;
Ext.apply(lastOptions.params, {
myNewParam: Math.random()
});
sDataStore.reload(lastOptions);
aaa=sDataStore.indexOfId(result)
(result is id of added record, getting from server)
But sDataStore.indexOfId(result) = -1 , and sDataStore not contents new record.

Why?

tnx, sorry for my english

Animal
26 Oct 2010, 6:53 AM
It's asynchronous.

raj_plays
26 Oct 2010, 8:31 AM
So, put the code that you want to run after the store has been loaded....


store.on('load', function(){//here})

saddanand
27 Oct 2010, 9:15 PM
but how do i catch the return type of the reload function

Animal
27 Oct 2010, 9:29 PM
The docs tell you that it does not return anything.

http://dev.sencha.com/deploy/dev/docs/?class=Ext.data.Store&member=reload

saddanand
27 Oct 2010, 9:39 PM
var reloadTask = {
run: function(){
runStore.reload();
//alert(" after reload hello");
},
interval: 2000 //1 second
}
i need a success/failure after the reload to start/stop my task, how do i get with that...
PlZ HelP

raj_plays
4 Nov 2010, 11:52 PM
use a on load event handler as


store1.on('load', function(store){alert(" after reload hello");})