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

Select-Unselect Child nodes based

7 Answers 118 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
NLV
Top achievements
Rank 1
NLV asked on 25 Jan 2010, 11:42 AM
Hello Team,

I'm facing the following issue with the Telerik Rad Tree View.

I've a tree view with multiple parent and child node relations. For instance consider a node A which has 5 child nodes a,b,c,d and e. Now i've set the CheckChildNodes property of the control to true.

Now i select the node A. So it will in turn select a,b,c,d,e. I'm unchecking a,b. Then i'm doing a postback which goes to another page and shows some content pertaining to the nodes selected. Now i click the "back" button in the browser and come to the original page. So the treeview shows the node A as selected and c,d,e as selected (and a,b as unselected). Fine till now.

Now if i unselect the node A, it is selecting all its child nodes a,b,c,d,e. If i check the node A, it is unselecting all its child nodes a,b,c,d,e. Exactly opposite!

Could some one provide some insights in this issue?

Thank you.

Regards
NLV

7 Answers, 1 is accepted

Sort by
0
NLV
Top achievements
Rank 1
answered on 25 Jan 2010, 12:19 PM
I guess it is a small glitch with the control. Check out the link for a sample.

http://dl.dropbox.com/u/3971218/Code%20Samples/RadTreeViewCheckUncheckSample.zip

Please help me with a fix for this at the earliest possible.

0
Accepted
Veselin Vasilev
Telerik team
answered on 27 Jan 2010, 12:08 PM
Hello NLV,

Please find attached the modified version of the page here.
Now the checked state will be preserved upon clicking the Back browser button.

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
NLV
Top achievements
Rank 1
answered on 27 Jan 2010, 06:13 PM
Thank you for your reply. That fixed the issue.

Is there a client side function to check all the nodes of a tree view equivalent to the server side CheckAllNodes() ? I've hundreds of nodes. I dont want to loop through everything.

Thank you.

NLV
0
Veselin Vasilev
Telerik team
answered on 28 Jan 2010, 03:31 PM
Hello NLV,

I am afraid you need to loop through all nodes and check them manually. Currently there is no single method to check/uncheck all nodes but I have added it as a feature request in our Public Issue Tracking System and you can go and vote for it here:
Publik Issue Tracking System

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
NLV
Top achievements
Rank 1
answered on 28 Jan 2010, 04:42 PM
Thank you for your reply.

NLV
0
Attila
Top achievements
Rank 1
answered on 13 Jan 2012, 04:17 PM
The file's no longer available; what was the solution?
0
Bozhidar
Telerik team
answered on 16 Jan 2012, 05:36 PM
Hello Attila,

The problem with the TreeView is that after the back button is pressed, it loses all it's state (checked nodes, selected nodes etc.). The CheckBoxes however keep their state. So in order to recreate the checked state of the treeview you have to hook on it's ClientLoad event and manually check all nodes that have their checkboxes checked. 

Here's the code that does the trick:
function clientLoad(sender) {
    var tree = sender;
    var allNodes = tree.get_allNodes();
 
    for (var i = 0; i < allNodes.length; i++) {
        if ($telerik.$(">div>.rtChk", allNodes[i].get_element()).is(":checked")) {
            allNodes[i].check();
        }
    }
}

 
All the best,
Bozhidar
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
Tags
TreeView
Asked by
NLV
Top achievements
Rank 1
Answers by
NLV
Top achievements
Rank 1
Veselin Vasilev
Telerik team
Attila
Top achievements
Rank 1
Bozhidar
Telerik team
Share this question
or