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

Hide expand icon in RadTreeList on no records

2 Answers 130 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Hans-Peter
Top achievements
Rank 1
Hans-Peter asked on 16 Apr 2015, 06:37 AM
using a RadTreeList I wonder how to hide the expand / collaps Icon when there are no records under parent item What I found within this platform ishttp://www.telerik.com/help/aspnet-ajax/grid-hide-expand-collapse-images-when-no-records.htmlbut as far as I can see this does not work for RadTreeList, doesn't it?

2 Answers, 1 is accepted

Sort by
0
Hans-Peter
Top achievements
Rank 1
answered on 16 Apr 2015, 08:23 AM

this blog pointet me to a possible solution but within ItemCreated the item.ID is null !?

protected void radList_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
{
      if (e.Item is TreeListDataItem)
      {
        if (e.Item.ID == 1)
        {
                Control expandButton = e.Item.FindControl("ExpandCollapseButton");
                if (expandButton != null)
                    expandButton.Visible = false;
        }
      }
  }

 

 

 

0
Hans-Peter
Top achievements
Rank 1
answered on 16 Apr 2015, 09:42 AM

so I think my solution should be

protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
{
    if (e.Item is TreeListDataItem)
    {           
        TreeListDataItem dataItem = e.Item as TreeListDataItem;
        if (dataItem != null)
        {
            myDataRow groupPermRow = dataItem.DataItem as myDataRow;
            if (groupPermRow != null)
            {
                DataRow[] childs = getChildDataByParentID(groupPermRow["ID"].ToString());
                if (childs == null || childs.Length < 1)
                {
                    Control expandButton = e.Item.FindControl("ExpandCollapseButton");
                    if (expandButton != null)
                        expandButton.Visible = false;
                }
            }
        }
    }
}

Tags
TreeList
Asked by
Hans-Peter
Top achievements
Rank 1
Answers by
Hans-Peter
Top achievements
Rank 1
Share this question
or