-
12 Jul 2011 2:35 AM #1
Data Store: isLoaded() or how to find out, whether a Data store is already loaded
Data Store: isLoaded() or how to find out, whether a Data store is already loaded
Hello,
Is there a (good/without problems) possibility (a method doesn't seem to exist, does it?) to find out whether a data store was already loaded?
Thanks.
-
12 Jul 2011 9:36 AM #2
-
12 Jul 2011 10:47 PM #3
-
13 Jul 2011 2:51 AM #4
-
13 Jul 2011 4:31 AM #5
just check the store's total items using store.getCount(). If its above 0 then your store has loaded, else not! getCount retrieves the cached records, and getTotalCount() retrieves the total items in the data set.
-
13 Jul 2011 5:40 AM #6
varunach,
1 at which moment?
2 if store was loaded with no data?
-
13 Jul 2011 7:57 AM #7
-
13 Jul 2011 8:14 AM #8
1) You can use it at whenever you need to perform any operation with the store or any component the store is attached too. No need of an event.
2) If the store is loaded with no data, the function will return 0. In this case you'll need to use the load event.
If you want to perform an operation after the store has loaded, then use the 'load' event of the store and write the business logic inside the load event function. Whenever the store gets loaded the event will be fired. The load event will be fired each time the store is loaded. So if you do call reload() function, the load event will be fired again.
-
13 Jul 2011 1:09 PM #9
dear icvg,
if you wanna more, can you try byuself (practice if better than theory in this case) or could you explain more about your expectations (may be share code )
thx
-
17 Jul 2011 2:13 AM #10
You can add an isLoaded() method yourself:
or the equivalent Ext.extend().Code:new Ext.data.Store({ ... loaded: false, isLoaded: function() { return this.loaded; }, listeners: { load: function(store) { store.loaded = true; } } });


Reply With Quote