Apr 13, 2013, 4:30 AM
[OPEN] [#207] How to add a node with children
This worked in 1.x. I want to add a node with children to a tree. The new node contains 1 child but when added, it shows two children with the same id. What am I doing wrong?
<html>
<head>
</head>
<body>
<script type="text/javascript">
function addStuff() {
TreePanel1.getRootNode().appendChild([{
id: 'item1',
text: 'item1',
expanded: true,
children: [{
id: 'item1A',
text: 'item1A',
children: [],
leaf: true
}]
}]);
}
</script>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" Theme="Gray"
DisableViewState="true" Namespace="" />
<ext:TreePanel ID="TreePanel1" runat="server" Width="300" Height="450" Icon="BookOpen"
Title="Catalog" AutoScroll="true">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Add Stuff" Handler="addStuff();">
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Root>
<ext:Node Text="Composers" Expanded="true">
<Children>
<ext:Node Text="Beethoven" Icon="UserGray">
<Children>
<ext:Node Text="Concertos">
<Children>
<ext:Node Text="No. 1 - C" Icon="Music" Leaf="true" />
<ext:Node Text="No. 2 - B-Flat Major" Icon="Music" Leaf="true" />
<ext:Node Text="No. 3 - C Minor" Icon="Music" Leaf="true" />
</Children>
</ext:Node>
</Children>
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreePanel>
</form>
</body>
</html>
Last edited by Daniil; Apr 15, 2013 at 3:21 PM.
Reason: [OPEN] [#207]