How can I add a class name to rows only if rowGroup exist more than 1 row?

How can I add a class name to rows only if rowGroup exist more than 1 row?

AnuruddhaSLAnuruddhaSL Posts: 1Questions: 1Answers: 0

Link to test c
ase
:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

Answers

  • allanallan Posts: 63,214Questions: 1Answers: 10,415 Site admin

    You'll need to use rowGroup.startRender for this - it gives you the number of rows in the group, so you could add a class if that is greater than 1 - e.g.

    $('#myTable').DataTable( {
        rowGroup: {
            startRender: function ( rows, group ) {
                if (rows.count() > 1) {
                    $(rows.nodes()).addClass('many');
                }
                return group +' ('+rows.count()+' rows)';
            }
        }
    } );
    

    Allan

This discussion has been closed.