gpt4 book ai didi

javascript - ExtJS - 获取项目的完整路径

转载 作者:行者123 更新时间:2023-11-30 12:55:16 25 4
gpt4 key购买 nike

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

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

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

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

我该怎么做?

最佳答案

节点接口(interface) getPath() , 大概就是你想要的

getPath( [field], [separator] ) : StringGets the hierarchical path from the root of the current node.Available since: 4.0.4Parametersfield : String (optional)The field to construct the path from. Defaults to the model idProperty.separator : String (optional)A separator to use.Defaults to: "/"ReturnsStringThe node path

Here's a small sample

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()

});

关于javascript - ExtJS - 获取项目的完整路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19385583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com