简体   繁体   中英

Checkbox select all row with same field? Using kendo-ui

$(function () {
        var grid = $("#grid").kendoGrid({
            dataSource: { data: items, pageSize: 20 },
            sortable: true,      
            pageable: true,
            columns: [
                {
                    title: "Select All",                    
                    template: '<input type="checkbox" class="chkbx" />',
                { field: "Test1", title: "A" },
                { field: "Test2", title: "B" },
                { field: "Test3", title: "C" },
}).data("kendoGrid");

For exemple when I select checkbox at Test1 I want to select all line who have same data in field test 3.

You can have a function on checkbox click:

    $(document).on("click", ".chkbx", function() {

    });

Check if the class is the same. Then you can do your logic inside the function

if ($(this).is(':checked')) {
  var grid = $("#grid").data("kendoGrid");
  var selectedItem = grid.dataItem(grid.select());
  console.log(selectedItem); // selected row object;
  // loop elements, compare your values and and select lines/checkboxes


} else {

}

How to select a particular row problematically

    var row = grid.element.find("... whatever your criteria will be");
    grid.select(row);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM