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">&nbsp;&nbsp;&nbsp;</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

This discussion has been closed.