I am using the grouping method described here Row Grouping
and it is working fine as is.
However I am now looking to be able to change what column the rows are grouped by, by changing a select option.
Now I found a question in the forums which has the following solution.
// Just redraw
function Redraw(ordered){
$('#table1').dataTable().fnSettings().aoDrawCallback.push( {
"fn": function ( settings ) {
var api = this.api();
var rows = api.rows().nodes();
var last=null;
api.column(ordered).data().each( function ( group, i ) {
if ( last !== group ) {
$(rows).eq( i ).before(
'<tr class="group"><td style="text-align:left" colspan="15">'+group+'</td></tr>'
);
last = group;
}
} );
}
} );
$('#table1').DataTable().draw(false);
}
Which I pass the column id the table should be grouped by. This is half what I need as it now ADDS the grouping on top of original grouping.
Is this due to the new function being pushed to the aoDrawCallback as opposed to replacing it?
Any idea how I can just replace the original callback (and remove grouping) then draw with the new callback function?
Any help appreciated!