PDA

View Full Version : Pull JSON Information from Existing Store



jreid42
29 Nov 2009, 9:57 AM
I am curious if this is possible and how I would go about it. I have an existing store that is filled with a JSON object.

I want to be able to pull information from a specific record in that store and use one of its fields as the data for my store.

Example.


{ "rows": [
{"name":"bob", "dates": [
{"year":1999,"day": 30},
{"year":2001,"day":15} ]}
{"name":"frank", "dates": [
{"year":2000,"day": 12},
{"year":1899,"day": 21}
]},


In my main store I would have 2 records, one for bob and one for frank.

In my second store I want to pull from one of the records just the dates object, so if I targetted this second store at bob I would get 2 records, one for 1999 and one for 2001; if I targetted it at frank I would get 2000, and 1899.

I suppose my question is; knowing how to select the row, how do I get the original JSON data for a specific record in a JSONStore? Is this JSON object capable of being passed to another JSON Store, or a MemoryProxy or something? I am just not sure the direction to take.

The reason I want to do this is to reduce the number of AJAX calls I make while still having access to a lot of information.

Thanks.

stephen.friedrich
30 Nov 2009, 2:29 AM
I think this should work:

mainStore.findBy/find/getById to get the record of the main store (or probably via RowSelectionModel.getSelected())

var detailJsonData = record.data.years;

then

detailStore.loadData(detailJsonData)