View Full Version : Nested model

7 Feb 2013, 3:26 AM
I am new to ExtJS and have few difficulties with it. I have a nested model from json, for example:

{ "data": {
"parentField": "value1",
"children" : [{
"childField": "value2",
}, {
"childField": "value3",

I tried to use one page to edit the parent model with children model at the same time (having Documented Oriented Database children are written always inside parent), to change both a parent and children using one record. I'm implementing on one page form for parent, grid for parent.childrenStore (that was created inside the parent after it was created by reader) and connected grid with another form (as in: http://docs.sencha.com/ext-js/4-1/#!/example/form/form-grid.html). It is quite robust, and I still have many problems implementing it (like retrieving data changed in grid to save it back in record so that i can send this record via rest to database).

My question is: is there an easy way to deal with nested models (cause my doesn't look like it)?

I hope that I made my intention clear ;)

9 Feb 2013, 1:22 PM
So you want the form to deal with the parentField value and a grid for the children array?

12 Feb 2013, 3:36 AM
First I thought about form with iterative repetition of fieldsets for children, but couldn't find anything like that in extjs. That's why I am using grid and one fieldset for children which is updated based on what is selected in grid. And I already implemented it in most part. I believe it is not the best method to deal with nested model because after every change in children form I have to update grid store and use a reader to update my model in the overall form (there is duplication of data). That's why I would like to hear some advice/opinions how other people deal with nested models (changing just one child is out of question, because it is not relational database, and to change a child I have to post all nested model anyway).