[英]jQuery DataTables: check all checkboxes on page load
I have a grid which is based on jQuery DataTables Checkboxes
.我有一个基于
jQuery DataTables Checkboxes
的网格。 It pretty much looks like the basic example that gyrocode
have on theirwebpage Does anyone know if I can have all checkboxes checked when the table first loads please (including the master checkbox, the one at the top that checks/unchecks all with a single click)它看起来很像
gyrocode
在他们的网页上的基本示例有谁知道我是否可以在第一次加载表格时检查所有复选框(包括主复选框,顶部的一个单击即可选中/取消选中所有复选框)
I tried $("input.dt-checkboxes").prop("checked", true);
我试过
$("input.dt-checkboxes").prop("checked", true);
but that checks only the entries that are currently shown on the datatable's page但这仅检查当前显示在数据表页面上的条目
you can use cells.checkboxes.select()
, filter the cells but, but we actually return true for all rows here, a working fiddle :您可以使用
cells.checkboxes.select()
,过滤单元格,但是我们实际上在这里为所有行返回 true,这是一个工作小提琴:
...
'initComplete': function(settings){
var api = this.api();
api.cells(
api.rows(function(idx, data, node){
return true;
}).indexes(),
0
).checkboxes.select();
},
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.