[CLOSED] Returning null node

  1. #1

    [CLOSED] Returning null node

    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();
    Last edited by Daniil; Apr 30, 2013 at 1:35 PM. Reason: [CLOSED]
  2. #2
    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.
  3. #3

    Scenario

    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.
  4. #4
    Ok, that is clear.

    How do you load the nodes into the TreePanel?
  5. #5
    Click image for larger version. 

Name:	Untitled.png 
Views:	17 
Size:	21.9 KB 
ID:	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'.
  6. #6

    NodeCollection

    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.
  7. #7
  8. #8

    Code Implementation Problem

    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?
  9. #9

    Resolved

    I resolved it using some other way. But thanx for you kind response.

Similar Threads

  1. [CLOSED] TreePanel GetNodeById method always returning non-null
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 30, 2013, 6:12 AM
  2. Replies: 1
    Last Post: Nov 26, 2012, 4:49 PM
  3. [CLOSED] Raw property is null when adding a node
    By RCN in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 22, 2012, 9:50 PM
  4. Replies: 4
    Last Post: Jan 19, 2012, 10:29 AM
  5. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM

Posting Permissions