2
votes

We are using kendo treeview to display hierarchial datasource.

One of our requirement is to check/uncheck all children checkboxes when a parent is checked/unchecked, so we used checkChildren property to achieve this.

But the issue is when we uncheck a child, the parent should not get unchecked, even if we have one child inside the parent.

Can you please provide jquery code snippet to achieve this.

Thanks

1

1 Answers

2
votes

It is less complicated to write your own check children function. Just use this function in check event:

function onCheck(e) {
    var chbx = $(e.node).find('.k-checkbox input').filter(":first");
    var state = chbx.is(':checked');
    $(e.node).find(".k-group input").prop('checked', state);

    //check the dataSource elements
    $(e.node).find(".k-group li.k-item").each(function(i,v){
        e.sender.dataSource.getByUid($(v).attr('data-uid')).checked = state;
    });
}

Also, here is the snippet you want: http://dojo.telerik.com/AFOqA