我正在使用jquery数据表在我的网页上创建表格,因为我想添加具有分组列的新行。以下是我的要求
transactiondetails
customer
customer1
customer2
activity
activity1
other
customer
customer1
customer1
"drawCallback": function (settings, json) {
debugger;
`enter code here` var api = this.api();
var rows = api.rows({ page: 'current' }).nodes();
var last = null;
var catLast = null;
api.column(0, { page: 'current' }).data().each(function (group, i) {
if (last !== group) {
$(rows).eq(i).before(
'<tr class="group"><td colspan="5"><strong>' + group + '</strong></td></tr>'
);
last = group;
api.column(1, { page: 'current' }).data().each(function (group, i) {
if (catLast !== group && group === 'Agent') {
$(rows).eq(i).before(
'<tr class="group"><td colspan="5"><strong>' + group + '</strong></td></tr>'
);
catLast = group;
}
});
}
});