PDA

View Full Version : Undo node move in a Tree



treblereel
25 May 2010, 8:37 AM
Hi all, i have a problems with tree:
I dont wand to permit users to move nodes to root node, so i give id to root not and add check to beforemove,

but nothing happend, only waht i get just a log in console.


Thanx For ant help !!


jobTree = new Ext.tree.TreePanel ({
id: 'jobTreeId',
enableDD: true,
title: 'Jobs Tree',
width: '50%',
autoScroll:true,
frame:true,
animate: true,
height: 500,
width: 300,
containerScroll: true,
fitToFrame:true,
rootVisible:false,
loader: new Ext.tree.TreeLoader({
dir: 'asc',
url: '<?php echo base_url();?>job/getTreeCheck',
requestMethod: 'POST',
params: { level : 'root' }
}),
root: new Ext.tree.AsyncTreeNode({
id: 'jobTreeRootId',
}),
});



jobTree.on('beforemovenode', function(tree, node,oldParent, newParent, index) {
if(newParent.id != 'jobTreeRootId'){
Ext.Ajax.request({
url: '<?php echo base_url();?>job/moveJob',
params: {
nodeid: node.id,
newparentid: newParent.id,
oldparentid: oldParent.id,
dropindex: index
},
success: function () {

},
failure: function () {

}

});
}else{
console.log('movenodeback!');
console.log(newParent.id,oldParent.id);

oldParent.appendChild(node);
newParent.removeChild(node);
//oldParent.appendChild(node);

}
});