Oct 07, 2013, 7:03 AM
TreePanel Add new nodes direct method
i have a tree panel which does not include a root\ children in the markup.
<ext:TreePanel
ID="TreePanel1"
runat="server"
Height="400"
Width="200"
UseArrows="true"
AutoScroll="true"
Animate="true"
HideHeaders="true">
<Fields>
<ext:ModelField Name="guid" />
</Fields>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnNewt" runat="server" Text="New" StandOut="true" Icon="Add">
<DirectEvents>
<Click OnEvent="btnNew_click" Timeout="100000"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Flex="1" DataIndex="text" />
<ext:CommandColumn ID="CommandColumn2" runat="server" Width="40">
<Commands>
<ext:GridCommand CommandName="Select" Icon="Accept" ToolTip-Text="Select Project" />
</Commands>
<PrepareToolbar Handler="return record.data.leaf;" />
<DirectEvents>
<Command OnEvent="Project_TreeSelect" Timeout="100000">
<EventMask ShowMask="true"></EventMask>
<ExtraParams>
<ext:Parameter
Name="Values" Value="#{TreePanel1};">
</ext:Parameter>
<ext:Parameter Name="Valu" Value="node" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>
</Columns>
</ColumnModel>
</ext:TreePanel>
on page load i am doing this
Node root = new Node();
root.NodeID = "Projects";
root.Leaf = false;
root.Expanded = true;
root.Icon = Icon.ChartOrganisation;
foreach (var a in Projects)
{
Node n = new Node();
n.Text = a.ProjectName;
n.CustomAttributes.Add(new ConfigItem { Name = "guid", Value = a.ProjectId.ToString() });
n.Leaf = true;
n.Icon = Icon.Package;
root.Children.Add(n);
}
TreePanel1.Root.Add(root);
this works on page load , but if i call the same method again ( after some addition \ removal from the tree nodes ) the refresh does not happen . what am i doing wrong here ?
help is appreciated
Thanks
Rajat
<ext:TreePanel
ID="TreePanel1"
runat="server"
Height="400"
Width="200"
UseArrows="true"
AutoScroll="true"
Animate="true"
HideHeaders="true">
<Fields>
<ext:ModelField Name="guid" />
</Fields>
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server">
<Items>
<ext:Button ID="btnNewt" runat="server" Text="New" StandOut="true" Icon="Add">
<DirectEvents>
<Click OnEvent="btnNew_click" Timeout="100000"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Flex="1" DataIndex="text" />
<ext:CommandColumn ID="CommandColumn2" runat="server" Width="40">
<Commands>
<ext:GridCommand CommandName="Select" Icon="Accept" ToolTip-Text="Select Project" />
</Commands>
<PrepareToolbar Handler="return record.data.leaf;" />
<DirectEvents>
<Command OnEvent="Project_TreeSelect" Timeout="100000">
<EventMask ShowMask="true"></EventMask>
<ExtraParams>
<ext:Parameter
Name="Values" Value="#{TreePanel1};">
</ext:Parameter>
<ext:Parameter Name="Valu" Value="node" />
</ExtraParams>
</Command>
</DirectEvents>
</ext:CommandColumn>
</Columns>
</ColumnModel>
</ext:TreePanel>
on page load i am doing this
Node root = new Node();
root.NodeID = "Projects";
root.Leaf = false;
root.Expanded = true;
root.Icon = Icon.ChartOrganisation;
foreach (var a in Projects)
{
Node n = new Node();
n.Text = a.ProjectName;
n.CustomAttributes.Add(new ConfigItem { Name = "guid", Value = a.ProjectId.ToString() });
n.Leaf = true;
n.Icon = Icon.Package;
root.Children.Add(n);
}
TreePanel1.Root.Add(root);
this works on page load , but if i call the same method again ( after some addition \ removal from the tree nodes ) the refresh does not happen . what am i doing wrong here ?
help is appreciated
Thanks
Rajat