Row grouping based on 100 rows
Row grouping based on 100 rows
Link to test case: http://themeadow.se/ServiceProductions/
Debugger code (debug.datatables.net): adowug
Error messages shown: No error messages shown
Description of problem:
I'm using row grouping with counters based on this example: https://jsfiddle.net/lbriquet/ua4yLscx/.
The problem I have is that the grouping and the counter think that there's only 10 rows in the table but I've set that value to 100. I want it to group and count based on 100.
My code:
$(document).ready(function(){
var collapsedGroups = {};
var table = $('#errorTable').DataTable( {
"ajax": {
"url": "http://themeadow.se/ServiceProductions/cooperationErrors.php",
"dataSrc": ""
},
"pageLength": 100,
fixedHeader: true,
"columns": [
{"data": "@timestamp"},
{"data": "senderid"},
{"data": "receiverid"},
{"data": "logicalAdress_description"},
{"data": "tjanstekontrakt"},
{"data": "errorCode"},
{"data": "time_producer"},
{"data": "log-level"},
{"data": "serviceProducer_hsaId"},
{"data": "serviceProducer_description"}
],
columnDefs: [
{
searchPanes: {
show: false
},
targets: [0,2,6,7,8]
}
],
dom: "P<'myfilter'f>rlptip",
rowGroup: {
// Uses the 'row group' plugin
dataSrc: "logicalAdress_description",
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="11">' + group + ' (' + rows.count() + " anrop" + ')</td>')
.attr('data-name', group)
.toggleClass('collapsed', collapsed);
}
},
language: {
"decimal": "",
"emptyTable": "Ingen data tillgänglig i tabellen",
"info": "Visar _START_ till _END_ av _TOTAL_ anrop",
"infoEmpty": "Visar 0 till 0 av 0 anrop",
"infoFiltered": "(filtrerat från _MAX_ anrop)",
"infoPostFix": "",
"thousands": ",",
"lengthMenu": "Visa _MENU_ anrop",
"loadingRecords": "Laddar...",
"processing": "Bearbetar...",
"search": "Sök:",
"zeroRecords": "Inga matchningar",
"paginate": {
"first": "Första",
"last": "Sista",
"next": "Nästa",
"previous": "Föregående"
},
"aria": {
"sortAscending": ": Aktivera för att sortera stigande",
"sortDescending": ": Aktivera för att sortera fallande"
},
searchPanes: {
title: {
_: '%d filter valda',
0: 'Inga filter valda',
1: 'Ett filter valt'
}
}
}
});
$('#errorTable tbody').on('click', 'tr.dtrg-start', function () {
var name = $(this).data('name');
collapsedGroups[name] = !collapsedGroups[name];
table.draw();
});
});
This question has an accepted answers - jump to answer
Answers
RowGroup is applied only to the page displayed as a result the
rows
parameter is only the rows, for that group, that are displayed on the page. Maybe a technique like this SO thread will allow you to count all the rows in the group.Kevin
Thank you!