How to done row grouping at server side?
How to done row grouping at server side?
yogesh123
Posts: 5Questions: 4Answers: 0
Hi,
I have done the row grouping on client side and it works fine on client side ..But when it comes to server side the row grouping is not showing in proper way.it makes the separate group of individual parent row and each child row.I am stuck with this problem.
plz give me suggestion on this with example..
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Following the row-grouping example worked fine for me with server-side data. So if you are having an issue, we would probably need to see your code.
I try the server side grouping with your code.But it still not giving me satisfy result.Grouping is not done in proper way.datable group at each row.Here is my jquerry code and I am grouping the row on groupName field of json.
"drawCallback": function ( settings ) {
var api = this.api();
var rows = api.rows( {page:'current'} ).nodes();
var last=null;
} );
$('#example tbody').on( 'click', 'tr.group', function () {
var currentOrder = table.order()[0];
if ( currentOrder[0] === 3 && currentOrder[1] === 'asc' ) {
table.order( [ 3, 'desc' ] ).draw();
}
else {
table.order( [ 3, 'asc' ] ).draw();
}
and I am grouping the row on groupName field of json
Also sort by the same column that you group by or you will see a ton of group header rows. So if you are grouping by column 3, add in
order: [[ 3, 'asc' ]]
into your datatable code, where you have yourserverSide: true
. I also disable sorting withbSort:false
because while I like the row grouping, I really don't care for it when it has been sorted.