Remove expand/collapse icon on selected folders

5 posts, 1 answers
  1. Graham Berry
    Graham Berry avatar
    3 posts
    Member since:
    Jan 2009

    Posted 25 Apr 2010 Link to this post


    I have a requirement to have a node with child nodes but for the child nodes not to be made visible to the user. It is really to keep the whole structure in the same place. I thought by making all child nodes and/or leaves visible=false this would mean that the parent node would not have an expand/collapse icon but this was not the case.

    For example:

            Node A
                Section 1 (visible=false)
                    Part 1 (visible=false)
                    Part 2 (visible=false)
                Section 2 (visible=false)
                    Part 1 (visible=false)
                    Part 2 (visible=false)
                    Part 3 (visible=false)
                    Part 4 (visible=false)

    I was expecting that "Node A" would not have expand/collapse as nothing was visible below it.

    I found another forum entry that seemed to cover this but the attribute is no longer available;

    "Disable expand icon and labeledit" - Jun 27, 2007

    RadTreeNode node = this.radTreeView1.Nodes[0].Nodes["Search Folders"];  
    node.StateImageIndex = -1;

  2. Victor
    Victor avatar
    1349 posts

    Posted 03 May 2010 Link to this post

    Hi Graham Berry,

    Thank you for writing.

    I am afraid that RadTreeView's logic responsible for the expand/collapse images is not configurable. You will have to devise a mechanism which will add and remove child nodes dynamically. You can remove the expand/collapse images via RadTreeViewElement's ExpandImage, CollapseImage, HoveredExpandImage and HoveredCollapseImage properties but the expand collapse part will still be clickable.

    Write again if you need further assistance. If you choose to remove the images you can use the NodeExpandedChanging event and cancel it when appropriate.

    Write again if you need further assistance.
    Sincerely yours,
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Kenneth
    Kenneth avatar
    29 posts
    Member since:
    Sep 2004

    Posted 16 Sep 2011 Link to this post

    Is there any chance that you will support to remove the expand-icon/behaviour for certain nodes that are loaded on demand?
  5. Answer
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 20 Sep 2011 Link to this post


    you can show/hide the expand indicator in the NodeFormatting Event handler.

    In my demand-loading tree I use a helper object (TreeNodeInfo) in the .Tag Attribute and when loading the parent nodes, I already query the database for the number of potential child nodes.

    private void myRadTreeView_NodeFormatting(object sender, TreeNodeFormattingEventArgs e)
            TreeNodeInfo info = e.Node.Tag as TreeNodeInfo;
            if (info != null)
                if (info.PotentialChildNodes > 0)
                    e.NodeElement.ExpanderElement.Visibility = ElementVisibility.Visible;
                    e.NodeElement.ExpanderElement.Visibility = ElementVisibility.Hidden;

  6. Kenneth
    Kenneth avatar
    29 posts
    Member since:
    Sep 2004

    Posted 08 Mar 2012 Link to this post

    Thanks for the solution!
    (a little bit late reply ;) )
Back to Top
DevCraft banner