PDA

View Full Version : tree events



zvepr
26 Apr 2010, 12:14 AM
I've downloaded last 3.2 extjs version few days ago, and got some question now.

Here is a simple tree (from examples/tree/reorder.html in extjs package). The task is to make some validation on "beforemovenode" event - is it possible to move node A to node B. In my case - make that validation at ajax, at that sample i'll make it like a simple action:


Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;

var tree = new Tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'get-nodes.php',

root: {
nodeType: 'async',
text: 'Ext JS',
draggable: false,
id: 'src'
}
});

// render the tree
tree.render('tree-div');
tree.getRootNode().expand();

// here is my code: simple function call instead ajax
tree.on('beforemovenode', function(tree, node, oldParent, newParent, index){

tree.fireEvent("movenode", tree, node, oldParent, newParent, index);

return false;
});

});


also i tryed to use

node.fireEvent("move", tree, node, oldParent, newParent, index);
node.move(),
node.insertBefore()

and other variants... but it doesnt works properly or doesnt works at all.

give some correct exaple, please?

zvepr
27 Apr 2010, 1:34 AM
up