myTree.on('click',function(node){
if(node.isLeaf())
{
Ext.Msg.alert("You are in value ",nodeValue,"whose name is",nodeName);
alert("You are in value ",nodeValue,"whose name is",nodeName);
}
});
myTree is a TreeP开发者_Go百科anel. I'm getting a tree but click function is not working. I'm very new to extjs. Help me out.
Thanks in advance
Try this instead:
myTree.on('click',function(node){
if(node.isLeaf())
{
Ext.MessageBox.show({
msg: 'You are in text ' + node.text + ', whose id is ' + node.id,
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.INFO
});
}
});
Haven't tried it, but it looks very similar to what I have been working with today :)
You can define your tree like :
var myTree = new Ext.tree.TreePanel({
region: 'west',
id: 'navTree',
title: 'Items',
width: 200,
store: store,
split: true,
collapsible: true,
listeners: {
itemclick: {
fn: function (view, record, item, index, event) {
//the record is the data node that was clicked
//the item is the html dom element in the tree that was clicked
//index is the index of the node relative to its parent
nodeId = record.data.id;
htmlId = item.id;
if (record.data.leaf) {
Ext.Msg.alert("Alert", "leaf");
}
else {
Ext.Msg.alert("Alert", "Not leaf");
}
}
}
}
})
Looks like you are looking for:
node.value
node.name
OR (I'm not good with Ext)
node.nodeValue
node.nodeName
精彩评论