-
7 Feb 2013 3:26 AM #1
Unanswered: Nested model
Unanswered: Nested model
Hi!
I am new to ExtJS and have few difficulties with it. I have a nested model from json, for example:
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/#!...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).Code:{ "data": { "parentField": "value1", "children" : [{ "childField": "value2", }, { "childField": "value3", }] }}
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 #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,581
- Vote Rating
- 433
- Answers
- 3100
So you want the form to deal with the parentField value and a grid for the children array?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
12 Feb 2013 3:36 AM #3
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).


Reply With Quote