Select-Unselect Child nodes based

8 posts, 1 answers
  1. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 25 Jan 2010 Link to this post

    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
  2. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 25 Jan 2010 Link to this post

    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.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 27 Jan 2010 Link to this post

    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.
  5. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 27 Jan 2010 Link to this post

    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
  6. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 28 Jan 2010 Link to this post

    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.
  7. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 28 Jan 2010 Link to this post

    Thank you for your reply.

    NLV
  8. Attila
    Attila avatar
    1 posts
    Member since:
    Nov 2010

    Posted 13 Jan 2012 Link to this post

    The file's no longer available; what was the solution?
  9. Bozhidar
    Admin
    Bozhidar avatar
    1102 posts

    Posted 16 Jan 2012 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017