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

show/hide nodes

3 Answers 317 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andreas Kaech
Top achievements
Rank 1
Andreas Kaech asked on 24 Feb 2009, 12:39 PM
Hi Telerik,
my problem is a bit "off-topic" - but I'm interested in a efficient solution with "telerik functions":
For security reasons, I have to hide some nodes.
The problem is that I have only the show/hide information of the last node in a branch.
Now the question(s):
- How to hide/show nodes with something like node.get_parent()?
- Is a serverside approach the better one?

Thanks for answering,
Andreas

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 24 Feb 2009, 01:14 PM
Hello Andreas Kaech,

Hiding nodes on the client-side for security reasons may not be a good idea since malicious user can use the client-side API to show them back. Anyway you can use the set_visible(false) method to hide a node on the client-side. However I would recommend you hide the nodes from the server side.

Regards,
Albert
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Andreas Kaech
Top achievements
Rank 1
answered on 24 Feb 2009, 01:29 PM
Hi Albert,
I thought, that the serverside approach is the better one ;-) 
But how can I (recursively) hide/show nodes serverside - I remember, the only information, if a brunch is visible or not is in the last node of this brunch.

Sincerely,
Andreas
0
Shinu
Top achievements
Rank 2
answered on 25 Feb 2009, 09:00 AM
Hello Andreas Kaech,

I guess you want to show/hide the last node of the RadTreeView on based on condition. I tried the recursive function for achieving this functionality. Try the below code snippets.

CS:
public bool value = true//condition 
protected void Button2_Click(object sender, EventArgs e) 
    RadTreeNode node= (RadTreeNode)RadTreeView1.Nodes[0]; 
    hidenode(node); 
//Recursive function to hide the node 
public void hidenode(RadTreeNode node) 
    if (node.Nodes.Count > 0) 
    { 
        for (int i = 0; i < node.Nodes.Count; i++) 
        { 
            hidenode(node.Nodes[i]); 
        } 
    } 
    else 
    { 
        if (value) //check the condition, if you want it for each node 
        { 
            node.Visible = false// hide the node 
        } 
    } 

Thanks,
Shinu.
Tags
TreeView
Asked by
Andreas Kaech
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Andreas Kaech
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or