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

Select checked items when using load on demand

3 Answers 32 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Condorito
Top achievements
Rank 1
Condorito asked on 17 May 2010, 09:41 PM
Hi, we have a load-on-demand TreeView with checkboxes.  Is there a way to retrieve those nodes that have their checkboxes checked?  

I've tried to use this code to retrieve them, but it only seems to return one item every time no matter how many nodes' checkboxes I check:

 var tree = $find('<%=rpbPanelBar.Items(0).Controls(0).FindControl("rtvTreeView").ClientID %>'); 
        
         for (var k = 0; k <  tree.get_selectedNodes().length; k++) { 
            var node = tree.get_selectedNodes()[k];   
            var i = node.get_value(); 
            alert(i);   
         } 

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 19 May 2010, 01:44 PM
Hello Juan,

Well, in your code you are retrieving only the nodes that are selected (and you wan the checked ones). Also you take the selected nodes from the entire tree (not only from the expanded node).

In order to achieve your scenario, you have to retrieve the checked nodes and then to find which ones are children of the node that is being expanded.

Here is an example of how your function should look like (this is an event handler):
function onClientNodeExpand(sender, args)
{
     var tree = $find('<%=rpbPanelBar.Items(0).Controls(0).FindControl("rtvTreeView").ClientID %>');
     var expandedNode = args.get_node();
     var checkedNodes = tree.get_checkedNodes();
     var checkedNodesCount = checkedNodes.lenght;
 
     for (var i = 0; i <  checkedNodesCount; i++) {
        var node = checkedNodes[i];  
        if (expandedNode === node.get_parent())
        {
           // here goes the implementation of
           // your scenario about the checked nodes that are children
           // of the node that is being expanded
           alert(node.get_value());
        }
     }
}

I hope this solves your problem!


Regards,
Nikolay Tsenkov
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
Condorito
Top achievements
Rank 1
answered on 20 May 2010, 02:42 PM
Perfect!  Thanks...
0
Nikolay Tsenkov
Telerik team
answered on 20 May 2010, 05:09 PM
Hello Juan,

Glad to help you!


Regards,
Nikolay Tsenkov
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.
Tags
TreeView
Asked by
Condorito
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Condorito
Top achievements
Rank 1
Share this question
or