Home Ask Login Register

Developers Planet

Your answer is one click away!

Jacobian February 2016

ExtJS 6. Unable to add a node to a treepanel

For some reason, in ExtJS 6 I cannot do something that worked literally for years with previous versions of the library. I cannot add a new node to a selected one. This is the code I have:

//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

If I check "selected" node and "selected.firstChild", I see what I expect to see - just normal nodes:

console.log(selected); // <-- I see that it is indeed the node, I selected
console.log(selected.firstChild); // <-- it's ok.


tonymayoral February 2016

When the node is added, the parent remains collapsed. Maybe that's why you can't see it. Try expanding the parent node. Example:

selected.insertBefore(node, selected.firstChild);

Or maybe selected is a leaf node (not allowing children). You would have to selected.set('leaf', false) Please take a look at this working fiddle

Post Status

Asked in February 2016
Viewed 2,347 times
Voted 13
Answered 1 times


Leave an answer

Quote of the day: live life