2010-04-14 6 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. Я получаю дерево, но функция click не работает. Я очень новичок в extjs. Выручи меня.Ошибка в кодексе

Заранее спасибо

+0

Пожалуйста, измените запись и форматирование кода с помощью кнопки коды образца. – Simeon

ответ

0

Похоже, что вы ищете:

node.value 
node.name 

ИЛИ (я не очень хорошо с Ext)

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 ет он выглядит очень похож на то, что я работаю с сегодняшним днем ​​:)

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"); 
       } 
      } 
     } 
    } 
}) 
Смежные вопросы