View Full Version : Practical example of one to many relationship.

11 Apr 2013, 6:46 AM

I have been struggling with a form containing multiple combo boxes in a new project I have been working on.
The way I would usually do this is by utilizing nested callbacks and multiple ajax calls (via the combo boxes's stores).

I thought I would try to use the one to many relationships between models introduced in 4.x. I get everything working as far as fetching data is concerned, that is I can access a store of data with
model.children(), where one model has many children.

My idea was to use the store returned from
model.children() to populate a combo box.

I would be grateful if anyone that may have found an example of something similar post a link.



14 Apr 2013, 9:20 PM
In your top-most model's load call are you currently returning nested data that will also populate the children store?

15 Apr 2013, 3:32 AM
Yes that is what I am trying to achieve. I would like to have the ability to load a form and populate the store of a combo box by form.loadRecord() or something that resembles this.

I don't want to manually load the combo box.

15 Apr 2013, 1:03 PM
Unless you extend form / basicForm (or override loadRecord) I don't that you'll be able to get quite that brief with your code. Loading the record won't apply associated stores within it to fields in your form automatically. You'll have to script something to retrieve the records from the associated stores and add them to the combo's store.