View Full Version : [CLOSED] Returning null node

Apr 30, 2013, 5:06 AM
private static Node FindNodeById(NodeCollection items, string nodeID)
foreach (var item in items)
if (item.NodeID == nodeID)
return item as Node;
var node = FindNodeById((item as Node).Children, nodeID);
if (node != null)
return node;
return null;

public static Node FindNodeById(TreePanelBase tree, string nodeID)
return FindNodeById(tree.Root, nodeID);

I tried to use the above given function but it is returning null. Where did I make mistake?

string nodeId = "TEST";
var node = FindNodeById(this.GetCmp<TreePanel>("treePanel"), nodeId);
var parentNodeId = node.ParentNode.NodeID.ToString();

Apr 30, 2013, 6:16 AM
Hi Pawan,


creates a TreePanel's proxy, not a real TreePanel. So, it doesn't contain any nodes.

X.GetCmp() is a convenient way to extract data from the POST, but a TreePanel doesn't submit all the nodes automatically.

Also X.GetCmp() is helpful to update dynamically rendered controls.

I am not sure you can use, because of I don't quite understand the scenario.

Please provide more details what you are actually doing.

Apr 30, 2013, 6:47 AM
What I am trying to accomplish is I want to find the node from treepanel on the basis of node's id. And after getting that particular node I want to have it's parent node's id.

Thank You.

Apr 30, 2013, 9:27 AM
Ok, that is clear.

How do you load the nodes into the TreePanel?

Apr 30, 2013, 9:42 AM

Root nodes are added using above given form and child nodes are assigned to those root nodes by drag and drop from left hand side treepanel.
To accomplish the above one I have used custom model.
In the above screenshot, ACCOUNTI is the childNode of ASDF. In server side I can get the Id 'ACCOUNTING' and by using this Id I want to have the value 'ASDF'.

Apr 30, 2013, 10:06 AM
I think I can get the node with the help of NodeCollection. So how can I get NodeCollection from treepanel in server side. You said that X.GetCmp() gives me proxy treepanel which does not have nodes. So can you suggest me something else? It is urgent.

Apr 30, 2013, 11:17 AM
You should submit the nodes.

Apr 30, 2013, 11:26 AM
I can't access my treepanel by using following code snippet.


I am using MVC.

Isn't there any way by which I can get root node of a particular node with the help of Node Id?

Apr 30, 2013, 11:56 AM
I resolved it using some other way. But thanx for you kind response.