Conditional grouping
Conditional grouping
berk bzn
Posts: 1Questions: 1Answers: 0
Hi.
I'm trying to create a BOM list. I grouped the table. It needs to be grouped in some rows. If 'Mont YMamül' in the column is 1, let it be the group. How can I do that or I can also get an alternative solution suggestion.
I want to make a table like this.
$(document).ready(function () {
var groupColumn = 0;
var table = $('#example1').DataTable({
columnDefs: [{ visible: false, targets: groupColumn }],
displayLength: 10,
ordering: false,
drawCallback: function (settings) {
var api = this.api();
var rows = api.rows({ page: 'current' }).nodes();
var last = null;
api
.column(groupColumn, { page: 'current' })
.data()
.each(function (group, i) {
if (last !== group) {
$(rows)
.eq(i)
.before('<tr class="group"><td colspan="8">' + group + '</td></tr>');
last = group;
}
});
},
})
});
Answers
Sorry I don't understand your requirement. Maybe you are looking for the Multilevel grouping capability of the RowGroup extension. The basic RowGroup extension configuration does what your code is doing. It grew out of this example which is your above code.
Kevin