Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event that fires once the store has data

I have a proxy store that fills through two different ways - either via loadData, or via load.

I have certain actions that should take place once the store is filled; namely, a certain record should be searched and selected:

preselectByName:function(name, groupName) {
    var store = this;
    if(store.preselected) return;
    store.preselected = true;
    store.on('load',function() {
        store.selectByName(name, groupName);
        store.preselected = false;
    },store,{single:true});
}

called like this:

if(store.isLoaded) store.selectByName(name, groupName);
else store.preselectByName(name, groupName);

This code works fine if the store fills via load, but not via loadData.

  • Is there another event that is fired from both load and loadRecord?
  • How else would I implement a listener that fires on any of the two events, whichever comes first?
like image 538
Alexander Avatar asked Sep 02 '25 17:09

Alexander


1 Answers

  • datachanged (http://docs.sencha.com/extjs/6.2.1/classic/Ext.data.Store.html#event-datachanged)

is an event, that fires from both load and loadRecord, but be careful, it fires from any change that made to the dataset.

Besides: I usually use this to find the event that I need in ExtJs:

Ext.util.Observable.capture(myObj, function(evname) {console.log(evname, arguments);})

It captures all ExtJs events, fired by the myObj component and logs it to the console.

  • Or you could create a custom event, which you fire manually on load and after loadData, like:

store.on("load",function(){store.fireEvent("myload")})

and

store.loadData(...)

store.fireEvent("myload")

then

store.on("myload",function(){...})

like image 184
Zsolt Medgyesi Avatar answered Sep 07 '25 01:09

Zsolt Medgyesi