Obtain NodeID from parent node (nodeProxy)

  1. #1

    Obtain NodeID from parent node (nodeProxy)

    I am having an issue obtaining the nodeID from the parent node.

    First of all, the node that I am trying to access gets passed to me by direct event:


            
           protected void UserTypeClicked(object sender, DirectEventArgs args)
            {
                SubmittedNode node = ((TreePanel)sender).SelectedNodes[0];
    
                BugHelper.Assert(node.NodeID != null || node.NodeID != "", "Missing Node ID");
                BugHelper.Assert(node.Text != null || node.Text != "", "Missing Node text");
    
                PANEL_TYPES panelType = ShowAppropriatePanel(node);
    
                fillPanel(panelType, node);
            }
    As a result, I can extract the NodeID from the original node.

    I am using a PanelTree as a break down of data, so in order to obtain the data for a particular piece of data, I need to first consult the parent (which category is the data under)

    Now here is the tricky part.

    In this case, I am now juggling three different Node types : Node, SubmittedNode, ProxyNode. The last two are not castable to Node.

    In order to obtain the parent NodeID I am currently stuck trying to obtain it this way:

    ((TreePanel)node.Tree).GetNodeById(node.NodeID).ParentNode().[???]
    which is now a ProxyNode. The issue is the ProxyNode does not have a function or property that lets me know the NodeID

    Is there a way to obtain the basic Node type from a ProxyNode? If not, is there a way for me to extract the NodeID? Is it named something different?
  2. #2
    The answer is very simple. Maybe this is something worth adding into EXT.NET, although it is just a standard recursive algorithm that searches the entire tree (provided that the tree is not organized in any specific way)

     public class EXTHelper
        {
            public static Node findElementInTree(Node currentNode, string nodeID)
            {
                if (currentNode.NodeID == nodeID)
                {
                    return currentNode;
                }
    
                if (currentNode.Children.Count > 0)
                {
                    foreach (Node child in currentNode.Children.ToList())
                    {
                        Node foundNode ;
                        if ((foundNode = findElementInTree(child, nodeID)) != null)
                        {
                            return foundNode;
                        }
                    }
                }
    
                return null;
            }
    
        }
    I can simply pass in:

    EXTHelper.findElementInTree(node.Tree.Root.First(), node.NodeID).ParentNode;
    and provided I "know" that this is not the root, I can obtain the parent from it directly
    Last edited by sfedorov; Jul 02, 2013 at 9:02 PM.

Similar Threads

  1. Replies: 4
    Last Post: Mar 22, 2015, 4:04 PM
  2. [CLOSED] TreePanel with ContextMenu retrieve NodeID of node clicked
    By taylorjp2000 in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 13, 2012, 3:17 PM
  3. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  4. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  5. Obtain clicked node TreeView
    By jpbelli in forum 1.x Help
    Replies: 3
    Last Post: Jan 29, 2009, 11:55 AM

Tags for this Thread

Posting Permissions