Search code examples
kendo-uikendo-treeview

Kendo How can I check mark the root node


I am new to Kendo and I have a form that displays checkboxes that is 3 levels deep . The first level or root node contains a country, the 2nd node the state and the last node a city . They all have checkboxes next to them . I am trying to put a checkmark on the top root node if 1 or more children node gets a checkmark . This is my code

<div id="treeview"></div>

function CheckMark() {

    var treeView = $("#treeview").data("kendoTreeView");

    // This below is not working trying to checkmark the root node
    $("#treeview .k-item:first").prop("checked", true);
}

Solution

  • .k-item can contain any item like li, div tags etc. So you have to specify .k-checkbox

    $("#treeview .k-checkbox:first").prop("checked", true);