PDA

View Full Version : How can I specify explicitly on expansion of a particular node by the user



YanniShin
2 Apr 2008, 9:53 PM
Hi,

It expands all the nodes in the tree. How can I specify explicitly on expansion of a particular node by the user, the action should happen.

Please provide some pointers to this problem.

evant
2 Apr 2008, 9:55 PM
myTree.on('expandnode', function(node)
{
if (node.id == 1)
{
//do something special
}
}
);

YanniShin
3 Apr 2008, 1:09 AM
Thanks for your help!
But I Know,How can I specify explicitly on expansion of a particular node by the user when tree render.



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

var tree = new Tree.TreePanel({
el:'treeBox',
border : false,
autoScroll:true,
animate:true,
rootVisible:false,
enableDD:true,
//selModel: new Ext.tree.MultiSelectionModel(),
containerScroll: true,
loader: new Tree.TreeLoader(),
collapseFirst:false
});

// set the root node
//var root = new Tree.TreeNode(
var root = new Tree.AsyncTreeNode(
//{text: 'Tree',allowDrop:false,id:'D10'}
<c:out value='${treeNode}' escapeXml='false' />
);

/*
var json = [<c:out value='${treeNode}' escapeXml='false' />];

for(var i = 0, len = json.length; i < len; i++) {
root.appendChild(tree.getLoader().createNode(json[i]));
}
*/


tree.setRootNode(root);

tree.render();
//tree.expandAll();


/*
var CallBackHandler = {success: handleExpand};

function handleExpand() {
var n = tree.getNodeById("D10");
alert(n);
if (n !== undefined) {
this.tree.getLoader ().load (n);
n.expand (true, true);
}
}
*/


//root.expand(false,false,CallBackHandler);
//root.expand(false,false,handleExpand);
root.expand(false, false, function() {
root.firstChild.expand(false);
});

tree.on('beforenodedrop', doDrop);
tree.on('click', doClick);

root.on('expandnode', function(node) {
alert(node.id);
if (node.id == "DELETE") {
alert("1");
}
});

Ext.get('expand').on('click', function() {
tree.expandAll();
});

Ext.get('collapse').on('click', function() {
tree.collapseAll();
});
});