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

Determine if item is parentnode

2 Answers 92 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 12 Apr 2011, 12:07 PM
Hello,

I have a Treelist that binds data that is not more then 1 level deep (Parent and 0 or 1 child). Now I have a button bind to each itemrow. What I want is that only the parentitem show the button (not the childitem). Is there a way in the ItemDataBound event to determine is a item is the parentnode (hasParent property) so I can only show the buttons for the parentitems?

Thanks in advance.

Kind regards,

Patrick

2 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 12 Apr 2011, 01:20 PM
Hi Patrick,

Yes, you can check the HierarchyIndex of the data item. Root level items always have a NestedLevel = 0:

protected void RadTreeList_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
{
    if (e.Item is TreeListDataItem)
    {
        var dataItem = (TreeListDataItem)e.Item;
        if (dataItem.HierarchyIndex.NestedLevel == 0)
        {
            //this is a root item
        }
    }
}


Veli
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Patrick
Top achievements
Rank 1
answered on 12 Apr 2011, 01:57 PM
Thx that did the trick
Tags
TreeList
Asked by
Patrick
Top achievements
Rank 1
Answers by
Veli
Telerik team
Patrick
Top achievements
Rank 1
Share this question
or