PDA

View Full Version : store.add question



AssetWorks
8 Mar 2013, 9:10 AM
The Question:
How can I add an associated store to the model I added to the store.
to understand the question better Let me show you what I have and you will see my problem

I have a grid that has many combinations and each combination has many child data



<Combinations xmlns="">
<Combination>
<Desc></Desc>
<children>
<child>
<data1></data1>
<data2></data2>
<data3></data3>
</child>
<child>
<data1></data1>
<data2></data2>
<data3></data3>
</child>
</children>
</Combination>
....(and so on)
</Combinations>

my problem is not reading the data but when I want to add a combination that I build. I need to insert/add all that data to the store in the same structure as when I'm reading
point being that if I do


store.add({Desc: 'New Combination'})

assume I have data already in the store from the server and that New Combination is the combination I build and want to push it in the store.
Now New combination has no associated store in it like the data that came back from the server.
see screen shots of the console.log(store) after I build my combo42266
record 0,1&2 have the associated store to them but record 3 (the one That I build and added has no associated store to it

how can I add this store to it or have be there when I add a record to it.
I have all the data I just need to push it in there.

any advise would be big help

mitchellsimoens
10 Mar 2013, 8:51 PM
Actually I just blogged about this earlier today: http://mitchellsimoens.com/2013/03/ext-js-4/client-side-associations/ Could be a nice coincidence.

AssetWorks
13 Mar 2013, 4:57 AM
this is great just what I needed
I had to do a store.add after creating the instance of the model.
this added the model with the asscociation.
I did not use store.loadRawData because my data is not JSON



var combo = Ext.create('Cam.model.CategoryCombinationModel', data, null, null, null, true);
store.add(combo)



on a side note: thanks for the link to your blog, very helpful stuff there