PDA

View Full Version : manage dependent stores



yd290276
5 Dec 2010, 12:30 AM
Hi all,
i'm often facing a recurrent issue when i have to program a component that contains two or more json stores that are dependent each others.

For exemple, i need store1 loaded before using store2. The basic example is :
- A combobox that use a store (contains 'id' and associative display values)
- A grid that use a store containing value ('id' in combo store) referenced in combobox store
- then i use a renderer in a column that converts 'id' into the display value

The problem is that depending the download time of each store, my grid doesn't correctly display a field as combobox store isn't still loaded when grid display.

I know i can use store events and then wait for combobox store and then run the creation of grid, but it doesn't feet my application logic as grid must be created in 'initComponent'.

Does anyone has an idea of how i can accomplish/manage this issue ?

Thanks !

yd290276
5 Dec 2010, 12:43 AM
humm... self reply !
I set grid store autoLoad to false and set combobox event handler "load" to call "load" method of grid component. It seems to work well.

If other ideas...

Condor
5 Dec 2010, 8:20 AM
Another method would be to have your server return the data for both in a single request and load both stores with the response.

yd290276
5 Dec 2010, 9:57 AM
yes, right, but my application is made of modules (zend framework :-)), so each store must request data from different modules/actions (in this case different actions in the same module) to get "users" and "groups".
If i was coding an action that do both request it will not be reusable.

So thank you for your help ! I see that ExtJS is sometimes difficult with event handling and dependencies !