PDA

View Full Version : Data stores within other stores - possible?



jwjames83
5 Sep 2011, 10:59 PM
Is it possible to have a data store array? I'd like to have one store contain one or more other data stores. I'm not seeing a way to do it - but thought I'd ask.

Thanks!

skirtle
6 Sep 2011, 2:19 AM
It'd be more standard to use associations instead.

That said, it is possible to have stores within stores if you really want to. The data types for each field can be configured to be just about anything. By default fields have type auto so they won't change the value you pass in. If the value is another store then so be it.

It you want the nested stores to be created via a reader then you'd need to write a custom convert function for your field that converts the data array into a store.

See:

http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Field

The following thread discusses the topic of stores within stores. It's ExtJS 3 so associations weren't an option but much of the material carries across:

http://www.sencha.com/forum/showthread.php?137479