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

Prevent client-side collapse of nodes

1 Answer 102 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Lars Melkevik
Top achievements
Rank 1
Lars Melkevik asked on 23 Feb 2011, 11:17 PM
Is there a way to prevent the user from collapsing nodes on the clientside? I need to keep the whole TreeList fully expanded at all times :-)

Best regards,
Lars Melkevik

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 24 Feb 2011, 02:47 PM
Hello Lars Melkevik,

I believe you are referring to the expand/collapse action of tree list item occuring on the server, as there is no client-side expand/collapse for RadTreeList as of the current version. If this is not what you meant, can you, please, clarify. To prevent expand/collapse commands, you can hide the expand/collapse buttons in each tree list data item. To do that, RadGrid's ItemCreated event can be used as follows:

protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
{
    if (e.Item is TreeListDataItem)
    {
        var dataItem = (TreeListDataItem)e.Item;
        var expandCell = dataItem.Cells[dataItem.HierarchyIndex.NestedLevel];
        if(expandCell.Controls.Count >0)
        {
            expandCell.Controls[0].Visible = false;
        }
    }
}

The result looks like this:

RadTreeList with removed expand/collapse buttons

Veli
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
TreeList
Asked by
Lars Melkevik
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or