gpt4 book ai didi

javascript - ExtJS 4.2.1,树,添加子节点到节点

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

我正在使用 ExtJS 4.2.1

当我点击它时,我试图将 child append 到叶子上。它最初是一片叶子,单击将其转换为一个文件夹,我想将叶子作为子节点 append 到该节点。

它在 Ext 3.4 中有效,但在 4.2.1 中似乎 appendChild() 方法有问题。由于 node.updateInfo(commit); 我们可以在 中找到 Uncaught TypeError: Object [object Object] has no method 'updateInfo' >appendChild().

这是一个非常简单的指令:

在 Ext3 中

    node.leaf = false; 
// add nodes in trees
for ( i =0 ; i < timesheetData.length ; i++ )
{
// we create a new node and state it's a timesheet
var newNode = new Ext.tree.TreeNode({
id : timesheetData[i].id,
text : timesheetData[i].text,
ts : true }) ;
node.appendChild(newNode);

}
node.expand();

在 Ext4 中

    node.set('leaf', false); 
// add nodes in trees
for ( i =0 ; i < timesheetData.length ; i++ )
{

node.appendChild({
id : timesheetData[i].id,
text : timesheetData[i].text,
ts : true });

}
node.expand();

Ext.tree.TreeNode 在 4.2.1 中不再存在。所以我尝试直接 append child 。但它不起作用!

我能做什么?

谢谢

最佳答案

在你的树监听器中试试这个:

itemclick: function( record, item, index, e, eOpts ){
item.appendChild({
text: 'Hi! I am a leaf',
leaf: true
});
}

关于javascript - ExtJS 4.2.1,树,添加子节点到节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17972815/

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