I have a button that I put an click event on.
I also have a TreePanel loaded with static JSON.
The TreePanel has an ItemID of projectTree
Inside my button click event I have:
var treeNode = projectTree.getRootNode();
treeNode.expandChildren(true); // Optional: To see what happens
treeNode.appendChild({
name: 'Child 4',
leaf: true,
element : 6
});
treeNode.getChildAt(2).getChildAt(0).appendChild({
name: 'Grand Child 3',
leaf: true,
element: 7
});
It does not add the nodes. What am I doing wrong?
Edited
var treeNode = this.child('#projectTree').getRootNode();
treeNode.expandChildren(true); // Optional: To see what happens
treeNode.appendChild({
name: 'Child 4',
leaf: true,
element : 6
});
// This one does not work
treeNode.childNodes(0).nextSibling.appendChild({
name: 'Grand Child 3',
leaf: true,
element: 7
});
projectTreedefined? Are there any errors? What version of ExtJS are you using? - forgivenson