ExtJs Store have method load and load method have callback function.
I have created a demo. you can check here Sencha fiddle
This function will create store and return.
function createStore(id) {
return Ext.create('Ext.data.Store', {
storeId: 'store_' + id,
alias: 'store.store_' + id,
proxy: {
type: 'ajax',
url: 'data.json',
timeout: 300000,
reader: {
type: 'json',
rootProperty: 'data'
}
}
});
}
For Example I have array of store. It contain storeId or alias.
var storeArry = [],
store = '';
for (var key = 0; key < 5; key++) {
storeArry.push(createStore(key).storeId);
}
On every store callback we can remove data from storeArray or maintain a variable for checking.
Ext.getBody().mask('Please wait..');
Ext.defer(function () {
Ext.getBody().unmask();
Ext.Array.forEach(storeArry, function (storeId) {
//For checking store is created or not
//if store is not created we can create dyanamically using passing storeId/alias
store = Ext.getStore(storeId);
if (Ext.isDefined(store) == false) {
store = Ext.create(storeId);
}
store.load({
callback: function () {
//On every store call back we can remove data from storeArray or maintain a veribale for checking.
Ext.Array.remove(storeArry, this.storeId);
if (storeArry.length == 0) {
Ext.Msg.alert('Success', 'All stored is loaded..!');
}
}
});
});
}, 3000);