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

RadTreeView Node Refresh

2 Answers 302 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
DEBAL
Top achievements
Rank 1
DEBAL asked on 16 Mar 2012, 03:49 PM
Hi Support
I'm using Telerik Rad Tree View for one of my asp.net application, my requirement is that :
 
There a Refresh Button in my telerik radpane container  .
User click on the nodes of tree view and different pages are open for that .
After they click on refresh button ( note : refresh button click because user can right click on any child node and create new node after that) I want to show user the last node where user was there (means from parent node to child node should remain expanded but other nodes that user did not click should closed, if click then expanded )  before click on refresh button .

How Can I do that , pl any suggestion

2 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 21 Mar 2012, 02:36 PM
Hi Debal,

You can refer to the Save the expanded state of the TreeNodes when the treeview is being bound upon each postback Code Library and use a similar code to save the state of the node that you need in your scenario.

Hope this will be helpful.

Greetings,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
DEBAL
Top achievements
Rank 1
answered on 22 Mar 2012, 11:12 AM
Thanks for your reply ,
I have Solved my problem like below simple  steps .
First I mentioned that , I have a refresh button ,  When user click on refresh button the node should expand where the user was there , I tried to do this by following code ... it is working .......

I write a filed first :

private string selectednode;

In Page_Load I want to store the value of Selected node in the variable :

if(this.treeview1.SelectedNode != null)
{
    selectednode = this.treeview1.SelectedNode.Value ;
}

Second In the click event of Button refresh :

private void btnRefresh_Click(Object Sender , EventArgs e)
{
   LoadTreeView(listofnodes); // this method call database and load all treeview nodes......this is not explained here.
   LastTreeNode();
}

Lastly ,

private void LastTreeNode()
{
 RadTreeNode node = this.treeview1.FindNodebyValue(selectednode);

if(node != null)
{
 if(node.ParentNode.value != string.Empty || node.ParentNode.value != null)
       {
             RadTreeNode node1 = node.ParentNode;
             node1.ExpandparentNodes();
             node1.Selected = true;
       }
 }
}

This is upto now I have done ..... pl help me someone to improve this code with better suggestion.
Thanks
Tags
TreeView
Asked by
DEBAL
Top achievements
Rank 1
Answers by
Plamen
Telerik team
DEBAL
Top achievements
Rank 1
Share this question
or