开发者

Extjs skip store load conditionally

This question is related to another question:

EXTjs gridfilter: How to clearfilter without reloading store?

My thinking is:

If there is 1 store and there are two functions (f1) and (f2) and both call store.load().

Both f1 and f2 will be called and the order is not guaranteed. Is there a way for f1 to check if store has already been开发者_JS百科 loaded by f2(and vice versa) and if loaded, skip the store.load command for f1.

What I am looking for is a method like:

 f1() {
     if (!store.isLoadedAsPartOfThisRequest() //true/false){
         store.load(params);
     }
 }

Is this possible?


Using store.getCount() is certainly a crude solution and creates inaccuracies if the loaded records happen to be none.

Sencha Support presented a solution:

'Check Store for lastOptions, if that exists then your Store has loaded at least once.'

It seems that lastOptions is no longer part of ExtJS 4.1. As a workaround, one can include and set an "isLoaded" boolean as part of a Store load override.


Here is my take on the issue: have two boolean variables for each store. Both will be initially set to false (Meaning the store is not loaded).

Now, both the stores will have a listener method for the 'load' event. The listener method will simply set the boolean variable if the store is loaded.

So, in your f1 and f2, you will check for the boolean values call reload. At the same time you will have find where and when you will set the boolean variables to false again.

I hope this helps you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜