Loke
Loke

Reputation: 349

ExtJS 4 associations and store.save()

I am using ExtJS 4, and have a model with an association hasMany defined.

ModelA -> hasMany -> ModelB

I use GridA to show the data from ModelA. On clicking a record in GridA, I use a rowSelect event to create GridB which use ModelA.ModelB() as a store.

It all goes well until I change a record in ModelB. The record does get updated in the hierarchy, but when I execute StoreA.save(), no change is sent back to the server. It does not notice the changes in associations. How do I save this data, without hacking the architecture?

I am expecting the Model to be able to save, exactly the way it loads.

Also when I change a record in ModelA, it gets sent back as only ModelA and not as ModelA->ModelB, even when that record has ModelB data.

Thanks

Upvotes: 4

Views: 2795

Answers (2)

Loke
Loke

Reputation: 349

Model relations are not well implemented yet, and ExtJS 4.1 is not making any improvements on the implementation either, other than a few important bug fixes. To learn more check my blog at http://blog.neolocus.com/2011/12/extjs-4-and-model-associations/

Upvotes: 1

dbrin
dbrin

Reputation: 15673

Yeah I don't think this whole model hierarchy is fully functional yet to the level that you expected. You can assume that only the things that this Doc mentioned work: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model

Upvotes: 1

Related Questions