Dec 03, 2014, 2:53 PM
[CLOSED] How to appendchild to leaf node from server
Hi,
I need to appendchild to a leaf node from code behind,
see my example: if I click btnAppendChild1 the node is added without problem,
but if I click btnAppendChild2 the node is not added because node "C2" is a leaf.
Please help me
Thank you
Jimmy
I need to appendchild to a leaf node from code behind,
see my example: if I click btnAppendChild1 the node is added without problem,
but if I click btnAppendChild2 the node is not added because node "C2" is a leaf.
Please help me
Thank you
Jimmy
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>
<script runat="server">
protected void btnAppendChild1_click(object sender, DirectEventArgs e)
{
Ext.Net.Node newNode = new Ext.Net.Node();
newNode.NodeID = "Child1_1";
newNode.Text = "Child 1_1";
newNode.Icon = Icon.Table;
newNode.Leaf = true;
newNode.AllowDrop = false;
newNode.AllowDrag = true;
this.tree.GetNodeById("C1").AppendChild(newNode);
}
protected void btnAppendChild2_click(object sender, DirectEventArgs e)
{
Ext.Net.Node newNode = new Ext.Net.Node();
newNode.NodeID = "Child2_1";
newNode.Text = "Child 2_1";
newNode.Icon = Icon.Table;
newNode.Leaf = true;
newNode.AllowDrop = false;
newNode.AllowDrag = true;
this.tree.GetNodeById("C2").AppendChild(newNode);
}
</script>
<html>
<head runat="server">
<title>Basic TreePanel - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:TreeStore ID="TreeStore1" runat="server">
<Root>
<ext:Node Expanded="true" Text="Root">
<Children>
<ext:Node Text="Child 1" NodeID="C1" Expanded="true">
<Children>
<ext:Node Text="Child A" Leaf="true" />
</Children>
</ext:Node>
<ext:Node Text="Child 2" NodeID="C2" Leaf="true" >
</ext:Node>
</Children>
</ext:Node>
</Root>
</ext:TreeStore>
<ext:TreePanel
id="tree"
runat="server"
UseArrows="false"
Animate="true"
Mode="Remote"
RootVisible="true"
ContainerScroll="true"
Height="300"
Width="300"
StoreID="TreeStore1"
>
</ext:TreePanel>
<ext:Button ID="btnAppendChild1" runat="server" Text="Append child to child 1" >
<DirectEvents>
<Click OnEvent="btnAppendChild1_click" />
</DirectEvents>
</ext:Button>
<ext:Button ID="btnAppendChild2" runat="server" Text="Append child to child 2" >
<DirectEvents>
<Click OnEvent="btnAppendChild2_click" />
</DirectEvents>
</ext:Button>
</body>
</html>
Last edited by Daniil; Dec 04, 2014 at 10:32 AM.
Reason: [CLOSED]