Feb 19, 2013, 5:55 PM
[CLOSED] TreePanel GetNodeById method always returning non-null
Hello,
Below is a dynamic tree panel example. I already have a problem with this code in another post. This post is for the return value of GetNodeById method. I want to check whether a node with a specific ID already exists in tree panel nodes. If not, I will create one and append children. If exists, I will get it and append children. The problem is that GetNodeById never returns 'null' to indicate that a node with given ID does not exist.
Thanks.
Below is a dynamic tree panel example. I already have a problem with this code in another post. This post is for the return value of GetNodeById method. I want to check whether a node with a specific ID already exists in tree panel nodes. If not, I will create one and append children. If exists, I will get it and append children. The problem is that GetNodeById never returns 'null' to indicate that a node with given ID does not exist.
Thanks.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
BuildMenuForUser();
}
}
protected void BuildMenuForUser()
{
Ext.Net.TreePanel menuTreePanel = new Ext.Net.TreePanel();
menuTreePanel.ID = "MenuTree";
menuTreePanel.RootVisible = false;
Ext.Net.Node menuRoot = new Ext.Net.Node();
menuRoot.NodeID = "MenuRoot";
menuRoot.Leaf = false;
menuTreePanel.SetRootNode(menuRoot);
Ext.Net.Node settingsNode = new Ext.Net.Node();
settingsNode.Text = "Settings";
settingsNode.Leaf = false;
settingsNode.NodeID = "SettingsNode";
menuTreePanel.GetRootNode().AppendChild(settingsNode);
Ext.Net.Node setting1Node = new Ext.Net.Node();
setting1Node.Text = "Setting 01";
setting1Node.Leaf = true;
menuTreePanel.GetNodeById("SettingsNode").AppendChild(setting1Node);
Ext.Net.NodeProxy checkSubNode = menuTreePanel.GetNodeById("NonExistingNode"); //still returning Ext.Net.NodeProxy
menuTreePanel.AddTo(MainMenuPanel);
}
</script>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Ext.NET Examples</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server"/>
<div>
<ext:Viewport ID="VP" runat="server" Layout="BorderLayout">
<Items>
<ext:Panel Title="Menu"
ID="MainMenuPanel"
runat="server"
Region="West"
Layout="AccordionLayout"
Collapsible="true"
Split="true"
Width="200"
MinWidth="200"
MaxWidth="400">
</ext:Panel>
<ext:TabPanel Title="Center"
ID="CenterPanel"
runat="server"
Region="Center"
Layout="FitLayout"
AutoScroll="true">
</ext:TabPanel>
</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>
Attachment 5660
Last edited by Daniil; Feb 20, 2013 at 12:40 PM.
Reason: [CLOSED]