PDA

View Full Version : Loading data from Store as per field name



damandeep.singh
6 Nov 2012, 4:23 AM
Hi,

I am using 2 stores:

Menu

{
"data":{
"item":[
{
"id": 1,
"Name":"Test"
},
{
"id": 1,
"Name":"Test"
}
]
}
}

Content:

{
"data":{
"item":[
{
"id": 1,
"Group":"Test",
"Content":"Hello How r u"
},
{
"id": 2,
"Group":"Test",
"Content":"Hi.. Good Morning"
},
{
"id": 3,
"Group":"Testing",
"Content":"Hello !!"
}
]
}
}

From first store named Menu I read Name as "Test" and using this I want to get the all the values of content.json with having group name : "Test" to show its itemTpl in my View.

Note: Content.json has multiple groups having same name "Test".

How to achieve this way.

Please Help.

Damandeep

Farish
6 Nov 2012, 5:11 AM
From what I understood, you want to filter the data in your 2nd store using some value from your first store. If this is the case, you can use the filter method of your store when the 2nd store is loaded:



store.on('load', function() {
store.filter({
property: 'Group',
value: 'Name',
exactMatch: true,
caseSensitive: true
});
});

then, only the filtered records will be displayed.

damandeep.singh
6 Nov 2012, 8:26 AM
Hi,

Thanks for prompt reply.
Well this is displaying the records but not filtered one..
Even when I click on next item to display records the old filtered records are still
visible.

Kindly help.

Farish
6 Nov 2012, 10:05 AM
Its not exactly clear to me what you are trying to do. Could you provide some code or image which would help in understanding your intention?