PDA

View Full Version : Make view wait till store is loaded.



carrollecc
17 Jan 2012, 9:09 AM
I am trying to use a custom renderer on a combo column and I need the store that the combo column refers to to be loaded before the view renders. Otherwise when the view is rendered the data is not there for store.find() to find anything. How can I go about forcing the view to wait on the store?

mitchellsimoens
17 Jan 2012, 9:25 AM
You can't. Best way is to have the store loaded before the view is ready.

carrollecc
17 Jan 2012, 9:40 AM
Ok. But in a MVC architecture, how could I go about loading that store before the view? I have put stores before everything in my app file and it still isn't loaded before the view is ready.

carrollecc
17 Jan 2012, 2:39 PM
Until someone or sencha comes up with a way to make the view wait for the store the only thing I can do is put an event on the store load which then refreshes the grid view which reruns the combo column renderer.

friend
18 Jan 2012, 10:42 AM
Check out the onLaunch() method of the Ext.app.Controller class. I think this is the intended hookpoint where you can initialize/preload any stores used by views.

carrollecc
20 Jan 2012, 6:55 AM
Well, I have the store's autoLoad on true. Sometimes it is loaded before the view is done rendering, but not most of the time. Therefore, I used the controller's onLaunch to set the store's onLoad event. The onLoad even runs a method which refreshes the grid view. When the grid view is refreshed, the custom renderer is rerun and everything works right.

The only problem is that during that small period of time the grid renders without the correct data, and then flashes with it. This is slightly annoying, but much less annoying than seeing the wrong data.