View Full Version : Determine if a store is already loaded

14 Dec 2010, 6:17 AM
How can I determine if a store is already loaded? I have a click function which populates a form from a database. I want the data from one of my stores to only be retrieved once, so I need a way to determine if that store is already loaded.

14 Dec 2010, 6:26 AM
You can use:

Store is loaded: Ext.isDefined(store.totalLength)
Store is loading: !!store.lastOptions && !Ext.isDefined(store.totalLength)

14 Dec 2010, 6:29 AM
Condor, that works great! Thanks for the help.

14 Dec 2010, 6:59 AM
For the "store is loading", do you mean: !Ext.isDefined(store.totalLength) && !store.lastOptions ??
The !!store.lastOptions just threw me for a loop. :)


14 Dec 2010, 7:25 AM
store.lastOptions is null or an object, so I added !! to force it to a boolean.

"!Ext.isDefined(store.totalLength) && !store.lastOptions" would mean that the store is neither loaded nor loading.

14 Dec 2010, 7:26 AM
Interesting. I've never seen that used before.