Results 1 to 2 of 2

Thread: TreePanel - beforenodedrop, beforemovenode problem

  1. #1
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    769

    Default TreePanel - beforenodedrop, beforemovenode problem

    Hello

    For manipulating with Nodes in TreePanel component i found functions what matched my requirements.

    First one BeforeMoveNode have oldParent and newParent node, second one beforeNodeDrop can check rawEvent with Ctrl Key.

    So my first question:

    Is there any way to check CTRL key in beforemovenode function? I debuged all params by firebug but didnt find something that would help.

    And now description of my problem:

    When you have got 3 nodes in your tree, and you drag 3rd node and drop it between 2nd and 3rd node, why is function beforenodedrop fired and beforemovenode not? Is it a bug or how i can remove this issue when user can drag node and drop it to "same path"?

    And another question:

    Can i see when is any event fired? For example: function beforenodedrop is fired everytime before beforemovenode etc.

    Thanks for help
    Zdeno

  2. #2
    Sencha Premium Member Zdeno's Avatar
    Join Date
    Nov 2009
    Location
    Prague
    Posts
    769

    Default

    Nobody know if it is a bug or im doing sth wrong?

    Here is code what im using.

    beforeNodeDrop delete or not team node - it depend on ctrl key
    beforemovenode move the node to another parent node

    but when beforemovenode isnt fired and beforenodedrop is i lose ownership of moving node:

    eg:

    Invisible root
    |
    -Node 1
    -Node 2
    -Node 3

    Everything is fine both handlers called.

    Invisible root
    |
    -Node 1
    <---drop room for Node 3
    -Node 2
    -Node 3

    Something is wrong - only beforenodedrop fired

    Invisible root
    |
    -Node 1
    -Node 2
    <---drop room for Node 3
    -Node 3

    I need this functionality because user can move node back to root, can move node or can copy node with key CTRL.

    Code:
    beforenodedrop: function( e ) {
    	var mask	= new Ext.LoadMask(this.getEl(), this.maskConfig);						
    	Ext.Ajax.request({
    		url: '?m=projects&a=ajax',
    		params: { 
    			"action" : "copyteamowner", 
    			"id": 118,
    			"teamid": e.dropNode.id,
    			"parent": e.dropNode.parentNode.id,
    			"delete": !e.rawEvent.ctrlKey
    		},
    		method: 'POST',
    		success: function (result, request) {
    			var resultObj = Ext.util.JSON.decode(result.responseText);
    			if ( !resultObj.success )						
    				Ext.MessageBox.alert('Error',resultObj.message);
    			mask.hide();							
    		},
    		failure: function(result, request) {
    			mask.hide();
    		}
    	});
    },
    beforemovenode: function( tree, node, oldParent, newParent, index ) {
    	var mask	= new Ext.LoadMask(this.getEl(), this.maskConfig);									
    	Ext.Ajax.request({
    		url: '?m=projects&a=ajax',
    		params: { 
    			"action" : "moveteam", 
    			"id": 118,
    			"teamid": node.id,
    			"target": newParent.id,
    			"parent": oldParent.id
    		},
    		method: 'POST',
    		success: function (result, request) {
    			var resultObj = Ext.util.JSON.decode(result.responseText);
    			if ( resultObj.success )
    			{
    				teamstree.getRootNode().reload();
    				teamstree.expandAll();
    				mask.hide();
    			}
    			else
    			{
    				Ext.MessageBox.alert('Error',resultObj.message);
    				mask.hide();
    			}															
    		},
    		failure: function(result, request) {
    			mask.hide();
    		}
    	});	
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •