This question is locked. New answers and comments are not allowed.
Arun Prasath
Top achievements
Rank 1
Arun Prasath
asked on 24 Jun 2010, 12:32 PM
Hi Atanas,
I am using the tree view with check box. Is there a way to check / uncheck all nodes in the tree view?
An example code would be very helpful.
Our customer ID is: JT359876
Many thanks,
Arun
I am using the tree view with check box. Is there a way to check / uncheck all nodes in the tree view?
An example code would be very helpful.
Our customer ID is: JT359876
Many thanks,
Arun
4 Answers, 1 is accepted
0
Accepted
Hello Arun Prasath,
To achieve your goal you need to find all checkboxes in the TreeView component. After you have a collection, containing all checkboxes of the TreeView, you need to traverse it and check/uncheck checkboxes shown in this forum thread open by you. For more information review this code snippet:
You can wire this method to a button. Thus you can check/uncheck all nodes in the treeview.
Regards,
Georgi Krustev
the Telerik team
To achieve your goal you need to find all checkboxes in the TreeView component. After you have a collection, containing all checkboxes of the TreeView, you need to traverse it and check/uncheck checkboxes shown in this forum thread open by you. For more information review this code snippet:
<script type="text/javascript">var checkAll = true; function ToggleCheckedItems(e) { var treeView = $('#TreeView').data('tTreeView'); var allCheckboxes = $('#TreeView').find("li:has(ul)").find('> div > .t-checkbox :checkbox'); $.each(allCheckboxes, function(index, checkbox) { $(checkbox).attr('checked', checkAll ? true : false); treeView.checkboxClick(e, checkbox); }); checkAll = !checkAll; }</script>Regards,
Georgi Krustev
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 21 Dec 2010, 04:00 PM
I created a jQuery function to uncheck ALL checkboxes in the tree view (parents and child and grandchild and etcetc, i.e. ALL) as the following:
function clearTreeView() {
var treeView = $('#TreeView').data('tTreeView');
var allCheckboxes = $('#TreeView').find("li:has(ul)").find('> div > .t-checkbox :checkbox');
$.each(allCheckboxes, function(index, checkbox) {
$(checkbox).attr('checked', false);
treeView.checkboxClick(null, checkbox);
});
}
But it only clears the FIRST parent checkbox. I am using the 2010Q3 version. Am I missing something?
Thank you.
function clearTreeView() {
var treeView = $('#TreeView').data('tTreeView');
var allCheckboxes = $('#TreeView').find("li:has(ul)").find('> div > .t-checkbox :checkbox');
$.each(allCheckboxes, function(index, checkbox) {
$(checkbox).attr('checked', false);
treeView.checkboxClick(null, checkbox);
});
}
But it only clears the FIRST parent checkbox. I am using the 2010Q3 version. Am I missing something?
Thank you.
0
Hi,
Regards,
Georgi Krustev
the Telerik team
Used jQuery selector is not correct. If you need to un/check all checkboxes then you should not search only for LI items with UL children. Here is correct jQuery selector:
$('#TreeView').find("li").find('> div > .t-checkbox :checkbox')Georgi Krustev
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
Arava
Top achievements
Rank 1
answered on 10 Feb 2011, 09:54 AM
Hi,
when all the checkboxes in the Treeview are unchecked my Check All check box shoul be automatically uncheked.
But this is not happening in my case.
As i am wrting on click of checkall checkbox all my checkboxes are getting checked .
And on uncheking the chek all chekoxes are the checkboxes are getting uncheked.This scenario is fine and this working according what you mentioned in below code.
But the above senario is not working fine.
Thanks & Regards,
Shilpa.
when all the checkboxes in the Treeview are unchecked my Check All check box shoul be automatically uncheked.
But this is not happening in my case.
As i am wrting on click of checkall checkbox all my checkboxes are getting checked .
And on uncheking the chek all chekoxes are the checkboxes are getting uncheked.This scenario is fine and this working according what you mentioned in below code.
But the above senario is not working fine.
Thanks & Regards,
Shilpa.