load multiple stores using a json with multiple roots
load multiple stores using a json with multiple roots
Hi ,
I have two stores. One being dependent on the other. Hence I would like to fire a query to the database only once and use the same json to load both the stores .
First of all, if you want someone to help you, you need to post your code, so we can reproduce the problem and give you the proper answer.
I can tell you that loadRawData works - I used it many times.
Now my advice is this. You said that one store is dependent on the other. Can you model the stores in a parent - child relationship? If that is the case, then you can populate only one store and the child data will be populated automatically (you need to include the child data in the parent, though).
If that is not the case, then I wouldn't follow the pattern from that page. First, the stores in their sample have the same structure (is that your case as well??). You can simply make an ajax call that gets the data for both stores and use loadRawData to load the stores data. You don't really need a third store. However, as I am writing this I was thinking that the approach in the article might work, but the parent store (mainStore from the sample) would return a row with two fields each field containing the data for the respective store.
To conclude, it would be better if you post your sample.
// The below store can be considered as a sub store.
var licenseJStore = new Ext.data.ArrayStore({
fields: ['id','text'],
proxy : {
type : 'memory',
reader : {
type : 'json',
root : 'list.licenseData'
}
},
autoLoad : false,
listeners :{
load :{
fn : function(){
alert('store loaded');
}
}
}
});
// The main store :
var featureJStore = new Ext.data.Store(
{
model : 'featureRecord',
pageSize : 500,
proxy : {
type : 'ajax',
url : 'featureList.data',
timeout : 300000,
reader : {
type : 'json',
root : 'list.featureData',
totalProperty : 'totalCount'
},
The JSON is of the form :
{
"list": {
"licenseData": [
{
"id": "abc",
"text": "abc"
}
]
},
"totalCount": "1",
"list": {
"featureData": [
{
"id": "23",
"name": "xyz"
}
]
}
}
The Error Message : TypeError: licenseJStore.loadRawData is not a function
Line 1885
Also Does loadRawData() trigger the load event on the store ?
I am using the feature store to load my grid and license store to load the list filter of the same grid.
Since for the list filter to work load event is required let me know if this approach will work ?