Collapse / Expand Click Groups
Collapse / Expand Click Groups
Hi All hope someone can help.
i'm currently building a table and it works however i've implemented this code to allow row grouping and child collapse/expand
rowGroup:{
dataSrc:'machineid',
startRender: function (rows, group) {
var collapsed = !!collapsedGroups[group];
rows.nodes().each(function (r) {
r.style.display = collapsed ? 'none' : '';
});
// Add category name to the <tr>. NOTE: Hardcoded colspan
return $('<tr/>')
.append('<td colspan="4"><i class="far fa-plus-square"> </i>' + group + ' (' + rows.count() + ')</td>')
.attr('data-name', group)
.toggleClass('collapsed', collapsed);
}
},
initComplete: () => {
$('#tbBody3').on('click', 'tr.group-start', function () {
var name = $(this).data('name');
collapsedGroups[name] = !collapsedGroups[name];
table.draw(false);
});
}
which came from another post on here a few years ago.
This does work however it's taking a full 3 seconds to collapses/open a row group. Is this because the table.draw is calling the data again and completely redrawing the table? the request this works with is going to a mongdb with 240,000 lines then filtering down to 3500, this only takes 0.3s to do then datatables only gets passed 3500~ rows of data so it should require to much processing.
if anyone can help that would be great
Answers
An
draw()
wouldn't get the data again, unless you haveserverSide
enabled, but given the volume of data in the table, it's likely to be slow.This section of the FAQ should help, it discusses various techniques to improve performance,
Cheers,
Colin
Can't say trying paging setting on or off made any difference or turning scrolly or scrollx on or off made a difference. The table it'self work really well loads fine it's just this aspect of the code.
if you look at this example
the collapse and open is near instant
http://live.datatables.net/kuruvipi/1/edit ![]
if you look at mine it takes between 2-3 seconds
(https://datatables.net/forums/uploads/editor/h4/zjx2q8mvhylc.gif "")
Can you create a test case that demonstrates the problem, that would be the most useful.
Colin