jeudi 20 juin 2019

Set all checkbox in Kendo Dropdowntree checked when load the page

I want to create kendo dropdowntree where when i load the page, all the checkbox is checked. Here is my code.

    @(Html.Kendo().DropDownTree()
                          .AutoWidth(true)
                          .Name("dropdowntree")
                          .DataTextField("Name")
                          .DataValueField("Id")
                          .CheckAll(true)
                          .HtmlAttributes(new { style = "width: 100%" })
                          .Events(events => events.Change("onChange"))
                          .Filter(FilterType.Contains)
                          .AutoClose(false)
                          .Checkboxes(checkboxes => checkboxes
                              .Name("checkedFiles")
                              .CheckChildren(true)
                          )
                          .DataSource(dataSource => dataSource
                            .Read(read => read
                            .Action("GetName", "CheckBox")
                        )
                        )
    )

I already doing some research and try the solution, but none if them work. For example, what i have try:

$(document).ready(function () {
   $("#dropdowntree input.k-checkbox").prop("checked", true);
})

This one also not work:

$(document).ready(function () {
    $("#dropdowntree").attr('checked', 'checked');
})

This one is work, but i need to set the value. What i need is it checked all by default, no need to set the value.

 $(document).ready(function () {
 var dropdowntree = $("#dropdowntree").data("kendoDropDownTree");
 dropdowntree.value(["1","2","3","4","5","6","7"]); 
 })

Other than all of these, i also try the solution in this link jquery set all checkbox checked and others solution. But still not work. I really need some advice. Thank you.




Aucun commentaire:

Enregistrer un commentaire