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

Remove expand/collapse icon on selected folders

4 Answers 732 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Graham Berry
Top achievements
Rank 1
Graham Berry asked on 25 Apr 2010, 12:00 PM
Hi,

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:

    Root
        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;

Thanks,
Graham

4 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 03 May 2010, 04:20 PM
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,
Victor
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.
0
Kenneth
Top achievements
Rank 1
answered on 16 Sep 2011, 10:04 AM
Is there any chance that you will support to remove the expand-icon/behaviour for certain nodes that are loaded on demand?
0
Accepted
erwin
Top achievements
Rank 1
Veteran
Iron
answered on 20 Sep 2011, 02:29 PM
Kenneth,

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;
            }
            else
            {
                e.NodeElement.ExpanderElement.Visibility = ElementVisibility.Hidden;
            }
        }
    }

Regards
Erwin
0
Kenneth
Top achievements
Rank 1
answered on 08 Mar 2012, 03:38 PM
Thanks for the solution!
(a little bit late reply ;) )
Tags
Treeview
Asked by
Graham Berry
Top achievements
Rank 1
Answers by
Victor
Telerik team
Kenneth
Top achievements
Rank 1
erwin
Top achievements
Rank 1
Veteran
Iron
Share this question
or