Disabling Expand Button

2 posts, 0 answers
  1. Kevin
    Kevin avatar
    3 posts
    Member since:
    Oct 2010

    Posted 31 May 2011 Link to this post

    Is there a way to disable the expand/collapse button?  I'm trying to get the tree structure and layout but always want the treelist expanded without allowing the user the ability to collapse the children.

    Thanks,
  2. Veli
    Admin
    Veli avatar
    2002 posts

    Posted 01 Jun 2011 Link to this post

    Hi Kevin,

    There are different approaches for doing that. You can:

    1. Hide the expand/collapse buttons in all items:

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

    2. Make the expand/collapse buttons disabled:

    protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
    {
        if (e.Item is TreeListDataItem)
        {
            Control expandButton = e.Item.FindControl("ExpandCollapseButton");
            if (expandButton != null)
            {
                ((Button)expandButton).Enabled = false;
            }
        }
    }


    3. Allow the buttons to be clicked, but cancel the ExpandCollapse command on the server:

    protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
    {
        if (e.CommandName == RadTreeList.ExpandCollapseCommandName)
        {
            e.Canceled = true;
        }
    }

    Any of the above 3 approaches should work in your case.

    Greetings,
    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
Back to Top