In this example, I will create a Kendo UI grid with multiple checkboxes and one checkbox in the header to check all the checkboxes inside the grid.
Below is the Angular code to bind the grid.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
function bindGrid() { var filterContain = { cell: { showOperators: false, operator: "contains", suggestionOperator: "contains" } } var DataColumn = [ { title: "<input id='chkAll' class='checkAllCls' type='checkbox'/>", width: "35px", template: "<input type='checkbox' class='check-box-inner' />", filterable: false }, { field: "ID", title: "ID", width: "10%", filterable: filterContain }, { field: "First_Name", title: "First Name", width: "10%", filterable: filterContain }, { field: "Last_Name", title: "Last Name", width: "10%", filterable: filterContain }, { field: "EmailID", title: "Email ID", width: "10%", filterable: filterContain }, { field: "Mobile", title: "Mobile", width: "10%", filterable: filterContain }, ]; $("#grd").kendoGrid({ selectable: "multiple", dataSource: { schema: { model: { fields: { ID: { type: "string" }, First_Name: { type: "string" }, Last_Name: { type: "string" }, EmailID: { type: "string" }, Mobile: { type: "string" }, } } }, pageSize: 100, }, height: 800, filterable: { mode: "row" }, groupable: false, scrollable: true, pageable: true, sortable: true, columns: DataColumn, }); $("#grd tbody").on("click", "tr", function (e) { var rowElement = this; var row = $(rowElement); var grid = $("#grdC").getKendoGrid(); if (row.hasClass("k-state-selected")) { row.removeClass('k-state-selected'); row.find('[type=checkbox]').prop('checked', false); e.stopPropagation(); } else { grid.select(row) row.find('[type=checkbox]').prop('checked', true); e.stopPropagation(); } }); $(".checkAllCls").on("click", function () { var ele = this; var state = $(ele).is(':checked'); var grid = $('#grd').data('kendoGrid'); if (state == true) { $('.check-box-inner').prop('checked', true).closest('tr').addClass('k-state-selected'); } else { $('.check-box-inner').prop('checked', false).closest('tr').removeClass('k-state-selected'); } }); } |
HTML code where you have to set the grid:
1 2 3 4 5 6 7 |
<table> <tr> <td style="padding-right:18px"> <div id="grd" class="k-content"></div> </td> </tr> </table> |
Conclusion
In this blog, I have written about how to handle the click event of the inner checkboxes.
In this blog, I have written about how to handle the click event of the inner checkboxes.
affordable asp.net Core 2.2.1 hosting, asp.net Core 2.2.1 hosting austria, asp.net Core 2.2.1 hosting brazil, asp.net Core 2.2.1 hosting czech, asp.net Core 2.2.1 hosting denmark, asp.net Core 2.2.1 hosting egypt, asp.net Core 2.2.1 hosting estonia, asp.net Core 2.2.1 hosting finland, asp.net Core 2.2.1 hosting greece, asp.net Core 2.2.1 hosting india, asp.net Core 2.2.1 hosting iran, asp.net Core 2.2.1 hosting iraq, asp.net Core 2.2.1 hosting israel, asp.net Core 2.2.1 hosting italy, asp.net Core 2.2.1 hosting luxembourg, asp.net Core 2.2.1 hosting noway, asp.net Core 2.2.1 hosting pakistan, asp.net Core 2.2.1 hosting paris, asp.net Core 2.2.1 hosting poland, asp.net Core 2.2.1 hosting portugal, asp.net Core 2.2.1 hosting russia, asp.net Core 2.2.1 hosting sout africa, asp.net Core 2.2.1 hosting switzerland, asp.net Core 2.2.1 hosting turkey, asp.net Core 2.2.1 hosting united arab emiratesm, belgium asp.net Core 2.2.1 hosting, Best ASP.NET Core 2.2.1 Hosting, Cheap ASP.NET Core 2.2.1 Hosting, european asp.net Core 2.2.1 hosting, france asp.net Core 2.2.1 hosting, germany asp.net Core 2.2.1 hosting, low cost asp.net Core 2.2.1 hosting, netherlands asp.net Core 2.2.1 hosting, recommended asp.net Core 2.2.1 hosting, reliable ASP.NET Core 2.2.1 Hosting, spain asp.net Core 2.2.1 hosting, top asp.net Core 2.2.1 hosting, uk asp.net Core 2.2.1 hosting