I have this extjs data store
mystore= Ext.create('Ext.data.Store', {
id: 'store_id',
fields: ['label', 'value', 'id', 'type'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'url/to/controller',
reader: {
type: 'json',
root: 'MyModel'
}
}
});
Is it possible with extjs configuration to make this store send ajax requests for new data on some interval (example 5 secs) automatically?
I want to use all functionality that extjs can provide so that I don't use php or additional javascript.
I have this extjs data store
mystore= Ext.create('Ext.data.Store', {
id: 'store_id',
fields: ['label', 'value', 'id', 'type'],
autoLoad: true,
proxy: {
type: 'ajax',
url: 'url/to/controller',
reader: {
type: 'json',
root: 'MyModel'
}
}
});
Is it possible with extjs configuration to make this store send ajax requests for new data on some interval (example 5 secs) automatically?
I want to use all functionality that extjs can provide so that I don't use php or additional javascript.
Share asked Oct 9, 2012 at 8:34 VladVlad 2,7737 gold badges52 silver badges106 bronze badges 1- 1 you could also look at server side push, such as websockets or et – Neil McGuigan Commented Oct 9, 2012 at 15:12
2 Answers
Reset to default 7You can use the TaskManager class to help with recurring tasks.
var task = {
run: function() {
mystore.load();
},
interval: 5000
}
// This will reload your store every 5 seconds
Ext.TaskManager.start(task);
// Call when you want to stop polling the server
Ext.TaskManager.stop(task);
Inside of my grid code, i've put the function below and it worked:
setInterval(function() // IN YOUR CASE, IT RELOADS EACH 5 SECONDS
{
storeReload = Ext.getStore("YourStoreHere");
storeReload.load();
}
,5000);
I hope that have helped!!