Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
tree.getNodeById not working
posted

I am using the Infragistics Build Version: 7.3.20073.1043 WebTree control. In the NodeChecked event handler, I'm using the client side getNodeById function of the tree control in the javascript. My code is as follows:

function folio_NodeChecked(treeId, nodeId, bChecked)
{
  
var selectedNode = igtree_getNodeById(nodeId);
  
var childNodes = selectedNode.getChildNodes();
  
var parentNode = selectedNode.getParent();
   if(bChecked)
   {
            var treeObject = igtree_getTreeById(treeId);
            var nodeObject = treeObject.getNodeById('24653');
            alert(nodeObject);
            nodeObject.setChecked(false);
  
}
}

The problem is that treeObject.getNodeById('24653') doesnt seem to return a valid node. It is null. Later I realized that 24653 is the DataKey and not the NodeId. When I fired the NodeChecked event against the Node with DataKey = 24653 to see what was the NodeId, it returned "ctl00ContentPlaceHolderMaintreeFolio_2_1_1_3". This doesnt seem useful in my scenario. My problem is that in a NodeChecked eventhandler, I have the DataKey for a different node and I want to check/un-check it using the node.SetChecked() function. How can I get the NodeId starting from the DataKey for a node.

Please help.

  • 7694
    posted

    Hello,

    You can use the property Tag of node  to set ID and get in client  side. Please take a look at the code below:

    C#
    UltraWebTree1.Nodes[1].Tag = "24653";

    JS code:
      var tag = selectedNode.getTag();

    Also you  have to use recursion method to find searched node.
    Sample recursion method:
    http://news.infragistics.com/forums/p/18534/67437.aspx#67437

    Hope this helps.