出于某种原因,在 ExtJS 6 中,我无法做一些在以前版本的库中确实可以工作多年的事情。我无法将新节点添加到选定的节点。这是我的代码:
//tree.store.getRootNode().insertBefore(node, tree.store.getRootNode().firstChild);
// ^^^ this works. Nodes are added to the root
selected.insertBefore(node, selected.firstChild);
// ^^^ this does not work, even though "selected" is just an ordinary node
// with leaf = false
如果我检查“selected”节点和“selected.firstChild”,我会看到我期望看到的内容 - 只是普通节点:
console.log(selected); // <-- I see that it is indeed the node, I selected
console.log(selected.firstChild); // <-- it's ok.
最佳答案
添加节点后,父节点保持折叠状态。也许这就是你看不到它的原因。尝试扩展父节点。示例:
selected.insertBefore(node, selected.firstChild);
selected.expand();
或者可能选择的是叶节点(不允许子节点)。您必须 selected.set('leaf', false)
请看一下 this working fiddle
关于javascript - ExtJS 6. 无法将节点添加到树面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35277526/