守则中的错误

时间:2010-04-14 13:06:52

标签: extjs

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是一个TreePanel。我得到一棵树,但点击功能不起作用。我对extjs很新。帮助我。

提前致谢

3 个答案:

答案 0 :(得分:1)

请改为尝试:

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
        });
    }
});

没有尝试过,但它看起来与我今天使用的非常相似:)

答案 1 :(得分:1)

您可以将树定义为:

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");
                }
            }
        }
    }
})

答案 2 :(得分:0)

看起来你正在寻找:

node.value
node.name

OR(我对Ext不好)

node.nodeValue
node.nodeName