dontbannedmeagain
dontbannedmeagain

Reputation: 480

Kendo UI TreeView Checkbox Select All

I had a similar situation like this DEMO.

  1. When I click on "Select All" on top of the table, it will check all the checkbox's below with different ID name on kendoTreeView?
  2. Why Im not able to check on parents node. Example if check the name "Steven Buchanan" all the child is check.

DEMO IN DOJO

Upvotes: 1

Views: 1092

Answers (1)

dontbannedmeagain
dontbannedmeagain

Reputation: 480

I already found the answer.

  1. I need to create onchange function on "Select All" checkbox. Source in here
 <input type="checkbox" id="chbAll" value="Uncheck" class="k-checkbox" onchange="chbAllCheck()" />
function chbAllCheck() {
  var checkButtonValue = $("#chbAll").val();

  if(checkButtonValue == "Uncheck"){
    $("#treeview .k-checkbox-wrapper input").prop("checked", true).trigger("change");
    $("#treeview_1 .k-checkbox-wrapper input").prop("checked", true).trigger("change");
    $("#treeview_2 .k-checkbox-wrapper input").prop("checked", true).trigger("change");
    $("#chbAll").val("Check");
  } else {
    $("#treeview .k-checkbox-wrapper input").prop("checked", false).trigger("change");
    $("#treeview_1 .k-checkbox-wrapper input").prop("checked", false).trigger("change");
    $("#treeview_2 .k-checkbox-wrapper input").prop("checked", false).trigger("change")
    $("#chbAll").val("Uncheck");
  }
}
  1. Need to replace this line checkboxes: { checkChildren: true }, . Source in here

Here a working demo in case someone needed

Upvotes: 1

Related Questions