Prevent client-side collapse of nodes

2 posts, 0 answers
  1. Lars Melkevik
    Lars Melkevik avatar
    7 posts
    Member since:
    May 2005

    Posted 23 Feb 2011 Link to this post

    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
  2. Veli
    Veli avatar
    2002 posts

    Posted 24 Feb 2011 Link to this post

    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

    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!
Back to Top