Hide expand icon in RadTreeList on no records

3 posts, 0 answers
  1. Hans-Peter
    Hans-Peter avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Apr 2015 Link to this post

    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. Hans-Peter
    Hans-Peter avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Apr 2015 Link to this post

    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;
            }
          }
      }

     

     

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hans-Peter
    Hans-Peter avatar
    3 posts
    Member since:
    Apr 2015

    Posted 16 Apr 2015 in reply to Hans-Peter Link to this post

    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;
                    }
                }
            }
        }
    }

Back to Top