1

我有 Ext.data.TreeStore。我使用 Ext.data.TreeStore。每个节点都有唯一的 ID

我需要这样的东西:当我选择节点时,我需要提醒它的完整路径(我的意思是:我的节点 ID、它的父 ID、它的父 ID 和根 ID)。

例如,如果我点击childOf(2childOf(Root))我需要 [root, 2childOf(Root), childOf(2childOf(Root))]

 ROOT
    1childOf(Root)
    2childOf(Root)
                  childOf(2childOf(Root))

我怎样才能做到这一点?

4

1 回答 1

3

NodeInterface getPath(),可能是你想要的

getPath([字段],[分隔符]):字符串
从当前节点的根获取分层路径。

可用时间:4.0.4

参数
字段:字符串(可选)
构造路径的字段。默认为模型 idProperty。
分隔符:字符串(可选)
要使用的分隔符。

默认为:“/”
退货
细绳
节点路径

这是一个小样本

Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
listeners: {
    itemdblclick: function( panel, record, item, index, e, eOpts) {
        alert(record.getPath('text','/'));
    }
},
renderTo: Ext.getBody()

});

于 2013-10-15T15:53:27.210 回答