Determine if item is parentnode

3 posts, 1 answers
  1. Patrick
    Patrick avatar
    20 posts
    Member since:
    Feb 2008

    Posted 12 Apr 2011 Link to this post

    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. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 12 Apr 2011 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Patrick
    Patrick avatar
    20 posts
    Member since:
    Feb 2008

    Posted 12 Apr 2011 Link to this post

    Thx that did the trick
Back to Top