This is a migrated thread and some comments may be shown as answers.

How to tell what get_parent() returns

2 Answers 118 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Jason Maronge
Top achievements
Rank 1
Jason Maronge asked on 31 Jan 2008, 04:45 PM
In the documentation of the TreeNode.get_parent() it states that get_parent()

Gets an instance of the parent-node, if any. RadTreeView object will be returned if the given node is a root node.

I have code that is expecting a null back if there is not a parent.  How do I tell if the object that is returned is a node or a treeview object.

Jason

2 Answers, 1 is accepted

Sort by
0
Accepted
Atanas Korchev
Telerik team
answered on 31 Jan 2008, 05:01 PM
Hi Jason,

Maybe you can use the following code:

if (node.get_parent() == node.get_treeView())  // root node

or test the node level for zero:

if (node.get_level() == 0) //root node

Regards,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jason Maronge
Top achievements
Rank 1
answered on 31 Jan 2008, 06:57 PM
Thanks
Tags
TreeView
Asked by
Jason Maronge
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Jason Maronge
Top achievements
Rank 1
Share this question
or