PDA

View Full Version : event handler triggers wrong function



ahsec
30 May 2012, 1:42 AM
Hello...
I have two tree panels ,they share the same stores, but that's all..they don't have any common identifier
I have defined for each one a different "itemexpand" handler... however, they both trigger the same function, more accurately
this is tree1

{ xtype: 'treepanel',
height: 410,
id: 'c_Att1',
padding: 5,
width: 260,
title: 'Showing all attributes Pages',
store: 'c_AttsTree',
viewConfig: {


},
listeners: {
select: {
fn: me.onC_Att1Select,
scope: me
},
itemclick: {
fn: me.onC_Att1ItemClick,
scope: me
},
itemexpand: {
fn: me.onC_Att1ItemExpand,
scope: me
}
}
}

and this is tree 2

{ xtype: 'treepanel',
height: 380,
id: 'win_Att1',
width: 280,
store: 'c_AttsTree',
x: 5,
y: 5,
viewConfig: {


},
listeners: {
itemexpand: {
fn: me.onWin_Att1ItemExpand,
scope: me
},
itemclick: {
fn: me.onWin_Att1ItemClick,
scope: me
}
}
}

the thing is...that for the second tree...both C_Att1ItemExpand and Win_Att1ItemClick are invoked and in that order...when I only expanded the second tree's root

I checked with the debugger and expanding tree2's root invokes onC_Att1ItemExpand

any ideas???????

Thank you

mitchellsimoens
7 Jun 2012, 12:31 PM
This is because since you are sharing the same store, when you make a change in one view, all views using that store will reflect the change. For the tree, the store actually holds the expand/collapse state so that is why the other is firing it also.