Product | Progress® Kendo UI® Grid for jQuery |
Product Version | Tested up to version 2017.2 621 |
How can I select all rows on all Kendo UI Grid pages?
The implementation of this functionality might lead to slow Grid performance.
persistSelection
configuration of the Grid totrue
.click
event of the master checkbox.click
event handler:<linkrel="stylesheet"href="https://demos.telerik.com/kendo-ui/content/shared/styles/examples-offline.css"><scriptsrc="https://demos.telerik.com/kendo-ui/content/shared/js/console.js"></script><divid="example"><divid="grid"></div><script>var oldPageSize=0;functiononChange(e){ kendoConsole.log("The selected product ids are: ["+this.selectedKeyNames().join(", ")+"]");};functiononClick(e){var grid=$("#grid").data("kendoGrid"); oldPageSize= grid.dataSource.pageSize(); grid.dataSource.pageSize(grid.dataSource.data().length);if(grid.dataSource.data().length=== grid.select().length){ grid.clearSelection();}else{ grid.select("tr");}; grid.dataSource.pageSize(oldPageSize);};$(document).ready(function(){$("#grid").kendoGrid({dataSource:{pageSize:10,transport:{read:{url:"https://demos.telerik.com/service/v2/core/Products"}},schema:{model:{id:"ProductID"}}},pageable:true,scrollable:false,persistSelection:true,sortable:true,change: onChange,columns:[{selectable:true,width:"50px"},{field:"ProductName",title:"Product Name"},{field:"UnitPrice",title:"Unit Price",format:"{0:c}"},{field:"UnitsInStock",title:"Units In Stock"},{field:"Discontinued"}]});var grid=$("#grid").data("kendoGrid"); grid.thead.on("click",".k-checkbox", onClick);});</script><divclass="box wide"><h4>Console log</h4><divclass="console"></div></div><style>.console div{height:6em;}</style></div>
The checkbox selectable column is available as of the Kendo UI R2 2017 SP1 release.