I hope this is a bug and not something stupid I am doing!
I have a layout with a grid control and elsewhere several tabs that give different information based on the currently selected row in the grid.
Therefore I have the following trigger on the selection model:
...
Code:
sm.addListener("selectionchange",function(sm){
try{
msgid=sm.getSelected().id
onMsgChange(msgid)
}
catch(e){}
}
, ds, true);
....
function onMsgChange(msgid){
var layout = Bijective.Operations.isNetting? messageDetailLayout: nettingDetailLayout
var cp = layout.getRegion('center').getActivePanel()
Bijective.Operations.cpmsg.setUrl(Bijective.constants.mvc + "/getMessage", {msgid:msgid,resulttype:'msgdata'})
Bijective.Operations.cpaudit.setUrl(Bijective.constants.mvc + "/getMessage", {msgid:msgid,resulttype:'txnaudit'})
...
cp.fireEvent("activate")
}
All of this works fine. A message is selected, the URL parameters are changed, and if there is an active tab, the fire event forces the tab to refresh.
I started to realise that as the application was used, the performance dropped and this made me notice that there were multiple refreshes in the ContentPanel, one for each row that had been selected.
So the first time though all would work as expected. The second time, two calls would be made, one with the parameters as per the first row and a second with the new parameters. The third would be similar with a call for all three parameters and so on.
So Each call to setURL was creating a new listener for onactivate.
digging deeper into setURL, I found the following:
Code:
setUrl : function(url, params, loadOnce){
if(this.refreshDelegate){
this.removeListener("activate", this.refreshDelegate);
}
this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
this.on("activate", this._handleRefresh.createDelegate(this, [url, params, loadOnce]));
return this.el.getUpdateManager();
},
It appears that the removeListener does nothing as it does not think the listener exists.
I think this is because the on() is getting a new delegate and hence the two are not matching
should it not be:
Code:
this.refreshDelegate = this._handleRefresh.createDelegate(this, [url, params, loadOnce]);
this.on("activate", this.refreshDelegate);
?
Just one last point, it would be great to have a method where just the parameters could be changed rather (and existing ones overridden) as I am sure it is more than likely that the URL stays the same but one or more parameters are (re)set.
Ian