1. #1
    Sencha User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
    blueboy is on a distinguished road

      0  

    Default TreePanel or TreeNode suspendEvents not working

    TreePanel or TreeNode suspendEvents not working


    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 ...

    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();
    		}
    	}
    }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Is this an Ext JS 3 question? There is no TreeNode in Ext JS 4
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
    blueboy is on a distinguished road

      0  

    Default


    Yes mitch, this is an ext js 3.x question...did i post this question in wrong section?

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    Quote Originally Posted by blueboy View Post
    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.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Apr 2008
    Posts
    10
    Vote Rating
    0
    blueboy is on a distinguished road

      0  

    Default


    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.