10263 : Is there an easy way to rownumbers into a grid? This is easy when you only have rootnodes, but with a tree a becomes very complex…

Question

Is there an easy way to  rownumbers into a grid? This is easy when you only have rootnodes, but with a tree a becomes very complex…

Answer

There is no such functions built into the components but if you want to do a number of the style x.y.z for a root node of x, and a subnode of y and a sub-sub-node of z you can use a recursive strategy like this:


public string GetIdentityOfNode(GridNode aNode)
{
  if (aNode.ParentNode==null)
  {
     // this was a root node return the index
     return aNode.Index.ToString();
  }
  else
  {
     return GetIdentityOfNode(aNode.ParentNode)+"."+aNode.Index.ToString();
  }
}

Leave a Reply