2010-04-14 101 views
0
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很陌生。幫幫我。代碼中的錯誤

在此先感謝

+0

請編輯文章,並使用代碼示例按鈕格式化你的代碼。 – Simeon 2010-04-14 13:08:48

回答

0

看起來你正在尋找:

node.value 
node.name 

OR(我不是分機好)

node.nodeValue 
node.nodeName 
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 
     }); 
    } 
}); 

還沒試過呢,b UT看起來很相似,我一直與今天:)工作

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