How can I group by three records with the drawcallback function

How can I group by three records with the drawcallback function

cristiantesvbcristiantesvb Posts: 1Questions: 1Answers: 0

$("#tabla_herramienta_prestar").empty().append(html);
var table = $('#tabla_herramienta').DataTable({
"columnDefs": [
{ "visible": false, "targets": 0 }
],
"order": [0, 'asc'],
"displayLength": 25,
"drawCallback": function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;

                api.column([0,1,2], {page:'current'} ).data().each( function ( group, i ) {
                    if ( last !== group ) {
                        $(rows).eq( i ).before(
                            '<tr class="group"><td colspan="5">'+group+'</td></tr>'
                        );

                        last = group;
                    }
                } );
            }
        } );

        // Order by the grouping
        $('#example tbody').on( 'click', 'tr.group', function () {
            var currentOrder = table.order()[0];
            if ( currentOrder[0] === 0 && currentOrder[0] === 'asc' ) {
                table.order( [ 0, 'desc' ] ).draw();
            }
            else {
                table.order( [ 0, 'asc' ] ).draw();
            }
        } );
This discussion has been closed.