How do I check all check boxes in a Kendo UI TreeView (parents and children nodes) based on a button click?

StackOverflow https://stackoverflow.com/questions/17958499

  •  04-06-2022
  •  | 
  •  

Question

This only checks the parent nodes:

$(function()
{
    $('#chkSelect').change(function()
    {
        if (this.checked)
        {
            $('#treeview input[type="checkbox"]').prop('checked', true);
        }
        else
        {
            $('#treeview input[type="checkbox"]').prop('checked', false);
        }
    });
});

Please note that the children nodes may or may not be expanded.

Was it helpful?

Solution

Figured out how to do it:

var treeView = $("#treeview").data("kendoTreeView");
    var userId = $('#user_id').val();

    $('#treeview').find('input:checkbox:checked').each(function()
    { ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top