[英]jquery Datatables row grouping with checkbox
I have a datatable in which I would like to apply row grouping to it. 我有一个数据表,我想在其中应用行分组。 Also included is a checkbox plugin.
还包括一个复选框插件。 I've tried the code listed on the datatables website , but I had no luck.
我已经尝试过datatables网站上列出的代码,但是我没有运气。 The api doesn't add the row for the grouping for the " City " column.
API不会为“ 城市 ”列添加用于分组的行。 The code I used for the grouping is shown below:
我用于分组的代码如下所示:
$(document).ready(function (){
$('#example').DataTable({
columnDefs: [{
targets: 0,
'checkboxes': {
'selectRow': true
}
},
{ "visible": false, "targets": 1 }],
select: {
style: 'multi'
},
order: [[1, 'asc']],
iDisplayLength: 10,
drawCallBack: function () {
var api = this.api();
var rows = api.rows({ page: 'current' }).nodes();
var last = null;
api.column(1, { page: 'current' }).data().each(function (group, i) {
if (last !== group) {
$(rows).eq(i).before(
'<tr class="group"><td colspan="6">' + group + '</td></tr>'
);
last = group;
}
});
}
});
});
I have the code in my jfiddle here . 我的代码在这里 。 Could the checkbox be interfering with the grouping?
复选框是否会干扰分组? Please let me know where I am going wrong.
请让我知道我要去哪里了。
Note: The checkbox is based on the plugin by gyrocode The datatables is version 1.10.12 注意:该复选框基于gyrocode的插件。数据表的版本为1.10.12
You're using incorrect option name, should be drawCallback
and not drawCallBack
. 您使用的选项名称不正确,应该是
drawCallback
而不是drawCallBack
。
See updated example for code and demonstration. 有关代码和演示,请参见更新的示例 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.