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

[Solved] Getting the checked nodes in client side

8 Answers 310 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Arun Prasath
Top achievements
Rank 1
Arun Prasath asked on 06 May 2010, 07:48 AM
Hi,
Is it possible to get all the checked nodes in a treeview in client side?
In the demo example it is going to the controller with a post method to get the checked nodes.
We want to access the checked nodes in the client side with out a post back.
Please let us know about it. Some sample code will be of great help.

Many thanks.

8 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 06 May 2010, 12:03 PM
Hi Arun Prasath,

It all boils down to jQuery selectors. Here is a code snippet:

var $checkedNodes = $('#TreeView :checked').closest('.t-item');

This will return the <li> tags of the checked nodes.

Regards,
Atanas Korchev
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
Arun Prasath
Top achievements
Rank 1
answered on 12 May 2010, 11:19 AM
Hi,
Thanks for the solution.

I have a treeview with three levels. i.e. parent node, then children nodes and each child node has some grand child nodes.

when I select 2 parent nodes, var $checkedNodes = $('#TreeView :checked').closest('.t-item');
returns only the first parent node with all the children.

Any help on this will be really great.

Many Thanks.
0
Arun Prasath
Top achievements
Rank 1
answered on 17 May 2010, 10:30 AM
Hi Atanas,
Could you please let us know about the problem with getting checked nodes in client side?

(Previous post)--->
I have a treeview with three levels. i.e. parent node, then children nodes and each child node has some grand child nodes.

when I select 2 parent nodes, var $checkedNodes = $('#TreeView :checked').closest('.t-item');
returns only the first parent node with all the children.

How can I get all the checked nodes in client side?

Thanks,
Arun
0
Atanas Korchev
Telerik team
answered on 17 May 2010, 10:41 AM
Hello Arun Prasath,

I tested the proposed solution in the treeview checkbox example. Everything worked as expected there - executing this (in FireBug):

$('#TreeView :checked').closest('.t-item');

returned all checked nodes. What is different in your case?

Regards,
Atanas Korchev
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
Wai Kei
Top achievements
Rank 1
answered on 20 Dec 2010, 04:50 PM
Hi,

    That might just be a jQuery question, but after getting a list of checked nodes (li tags) via the closest method in jQuery, how do you get the value within the checkbox input? The only way that I see is to parse the outerHTML from the element but that seems to be incorrect.

    Please advise.

Thanks
0
Atanas Korchev
Telerik team
answered on 21 Dec 2010, 08:52 AM
Hello Wai Kei,

 You can use the getItemValue method of the treeview:

var treeView = $('#TreeView').data('tTreeView');
var checkedNodes = $('#TreeView :checked').closest('.t-item');

var checkedValues = $.map(checkedNodes, function(node) {
      return treeView.getItemValue(node);
});

Regards,
Atanas Korchev
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
awni
Top achievements
Rank 1
answered on 30 Oct 2011, 06:00 PM
Hi, 
How would you do that with java script? I just want an array of nodes. 

thanks,
awni
0
Rafael
Top achievements
Rank 1
answered on 09 Apr 2012, 01:57 PM
how pass checkedValues in controller's method?
is it javascript array on string splitted by "," ?
Tags
TreeView
Asked by
Arun Prasath
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Arun Prasath
Top achievements
Rank 1
Wai Kei
Top achievements
Rank 1
awni
Top achievements
Rank 1
Rafael
Top achievements
Rank 1
Share this question
or