Ошибка в коде - PullRequest
       42

Ошибка в коде

0 голосов
/ 14 апреля 2010
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 ]

1 голос
/ 14 апреля 2010

Попробуйте вместо этого:

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

Не пробовал, но выглядит очень похоже на то, с чем я работал сегодня :) 1004 *

1 голос
/ 20 мая 2011

Вы можете определить свое дерево как:

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");
                }
            }
        }
    }
})
0 голосов
/ 14 апреля 2010

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

node.value
node.name

ИЛИ (с Ext у меня все плохо)

node.nodeValue
node.nodeName
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...