rosebrit3
rosebrit3

Reputation: 523

EXTJS 4 Tree drag and drop

Am trying to move nodes in a Tree panel in EXTJS 4. The locations of these nodes are stored in a SQL database. What should happen when i move the nodes is that, the id's of those nodes should get changed in the database, depending on the location on the tree. Till now, i have managed to get only the id of the parent node, and not the actual node itself. I dont understand why this is happening. Each time i move a node,its returning me the id of the parent node. Code is as follows:

function buildTree() {

consoleWrite('BUILD THE TREE!!!');

var tree = Ext.create('Ext.tree.Panel', {
    title : '',
    border : false,
    height : SYSTEM.panelHeight,
    viewConfig : {
        listeners : {

        },
        enableDD : true,
        plugins : {
            ptype : 'treeviewdragdrop'
        }
    },
    collapsible : false,
    useArrows : true,
    rootVisible : false,
    store : TREEst,
    multiSelect : false,
    singleExpand : true,
    id : 'PAGETREE',
    listeners : {
        afterRender : function() {
            MASK.tree.hide();
        },
                itemmove : {
            fn : function(v, node, oldParent, newParent, index) {
                  var nodeID = node.data.id;
                                     alert(nodeID);
            }
        }

This nodeID is printing the id of the parent node, as its stored in the database, and not the actual node itself. If anyone could provide me with guidance on how to proceed, that would be really great. Thanks in advance.

Upvotes: 0

Views: 3056

Answers (1)

Izhaki
Izhaki

Reputation: 23586

I don't think your itemmove params signature is correct. The API docs for 4.1 say:

itemmove( Ext.data.NodeInterface this, Ext.data.NodeInterface oldParent, Ext.data.NodeInterface newParent, Number index, Object eOpts )

So your node is actually referring to oldParent.

Upvotes: 1

Related Questions