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
685
GetNodeByKey needs a key
posted

When loading from a standard adapter the key for each item in the tree is not set. 

 If there is no key the the following code will no work.

 

UltraTreeNode TreeNodeVar = this.ultraTree2.GetNodeByKey(Convert.ToString(var.ToString()));

if (TreeNodeVar ! = null)

{

TreeNodeVar.ParentNodesCollection.Remove(TreeNodeVar);

}

 

What step am i missing please ?

Thought about looping through tree and adding the key but cannot see where that would best be located, and there is probably an easier way , right?

 

 

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Key here refers to the Key property of node. The tree can't get the key from the data, because it would not know which field in the data to use. And also, the keys of the nodes have to be unique across the entire tree. 

    So if you want to assign a key to the bound nodes, the best place to do this would be the InitializeDataNode event. You could generate a unique key based on your data and set the Key property of the node. 

Children
No Data