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

Disabling Expand Button

1 Answer 173 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 01 Jun 2011, 03:07 AM
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,

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 01 Jun 2011, 09:31 AM
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.

Tags
TreeList
Asked by
Kevin
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or