PDA

View Full Version : [CLOSED] Returning null node



pawangyanwali
Apr 30, 2013, 6:06 AM
private static Node FindNodeById(NodeCollection items, string nodeID)
{
foreach (var item in items)
{
if (item.NodeID == nodeID)
return item as Node;
else
{
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();

Daniil
Apr 30, 2013, 7:16 AM
Hi Pawan,

This

this.GetCmp<TreePanel>("treePanel")
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.

pawangyanwali
Apr 30, 2013, 7: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.

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

How do you load the nodes into the TreePanel?

pawangyanwali
Apr 30, 2013, 10:42 AM
6127

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'.

pawangyanwali
Apr 30, 2013, 11: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.

Daniil
Apr 30, 2013, 12:17 PM
You should submit the nodes.
http://examples2.ext.net/#/TreePanel/Basic/Submit/

pawangyanwali
Apr 30, 2013, 12:26 PM
I can't access my treepanel by using following code snippet.


this.TreePanel1.Root

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?

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