PDA

View Full Version : TreePanel or TreeNode suspendEvents not working



blueboy
3 May 2012, 10:31 AM
I have a treepanel on my page which has "click" and "expandnode" listeners registered to it.
Now I have a scenario in which based on user action I am expanding and collapsing node based on user selection. In this case I don't want the "expandnode" listener to be fired so I am calling its suspendEvents method before expanding a node (node.expand()). But the event is still getting fired. below is the snapshot of code ...



// tree panel definition
{
xtype: "treepanel",
title: "Title",
id: "someid",
rootVisible: false,
autoScroll: true,
bodyStyle : "padding:5px;",
root: new Ext.tree.TreeNode({
text: "All"
}),
listeners: {
click: function(inNode, inEvent) {
methodcall();
},
expandnode: function(inNode){
methodcall();
}
}
}

// after building the tree, I have to expand the nodes that has child nodes
// so calling this piece to expand the nodes and I dont want expandnode to be fired
// when i do so. I also tried treepanel.suspendEvents...still the event is getting fired like
// a gatling gun

for(var i=0;i<rootNode.childNodes.length;i++) {
var parentNode = rootNode.childNodes[i];
if(parentNode.hasChildNodes()) {
parentNode.suspendEvents(false);
parentNode.expand(); // this is the point where expandnode event is getting fired
parentNode.resumeEvents();
}
for(var j=0;j<parentNode.childNodes.length;j++) {
var childNode = parentNode.childNodes[j];
if(childNode.hasChildNodes()) {
childNode.suspendEvents(false);
childNode.expand(); // this is the point where expandnode event is getting fired
childNode.resumeEvents();
}
}
}

mitchellsimoens
7 May 2012, 6:52 AM
Is this an Ext JS 3 question? There is no TreeNode in Ext JS 4

blueboy
10 May 2012, 5:54 AM
Yes mitch, this is an ext js 3.x question...did i post this question in wrong section?

mitchellsimoens
10 May 2012, 8:07 AM
Yes mitch, this is an ext js 3.x question...did i post this question in wrong section?

Yeah, you posted in Ext JS 4.x forum, I moved it.

blueboy
21 May 2012, 11:22 AM
Looks like its a bug in Ext JS 3.x. I couldn't find a solution to this in any of the forum that had same scenario.