Paging with Row Grouping

Paging with Row Grouping

ChunkChunk Posts: 1Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
Hi, I've followed this example to add grouping rows to my table:

http://datatables.net/release-datatables/examples/advanced_init/row_grouping.html

It works well, but when you apply paging, it displays iDisplayLength number of rows plus the added grouping rows.

What's the best way to make it show iDisplayLength number of rows including the grouping rows?

Apologies if it's a stupid question, this is my first foray into the world of JQuery.

Any help would be appreciated.

[code]
$('#new_1').dataTable({
"fnDrawCallback": function ( oSettings ) {
if ( oSettings.aiDisplay.length == 0 )
{
return;
}

var nTrs = $('tbody tr', oSettings.nTable);
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
var sLastGroup1 = "";

for ( var i=0 ; i

Replies

  • jayalfredprufrockjayalfredprufrock Posts: 5Questions: 0Answers: 0
    edited June 2013
    I too was looking for a solution to this problem, and while I found lots of other people looking too, no real answers ever surfaced. Anyways, I came up with something that works well for me, and might be adapted for your case. It doesn't enforce the display length on a group level like you asked for, but it does prevent incomplete groups from displaying by dynamically altering the display length to fit the full group. Here's a little code:

    [code]
    groupTableRows = function(oSettings){

    if ( oSettings.aiDisplay.length == 0 )
    {
    return;
    }

    var nTrs = $('> tbody > tr', oSettings.nTable);

    var $table = $(oSettings.nTable );

    var index = oSettings._iDisplayStart + nTrs.length -1;

    if (index+1 < oSettings.aiDisplay.length && !$table.hasClass('group-processed')){

    var sLastGroup = oSettings.aoData[ oSettings.aiDisplay[index]]._aData[0];

    var missing_rows = 0;

    for ( var j=index+1 ; j 0){

    oSettings._iDisplayLength = nTrs.length + missing_rows;

    $table.addClass('group-processed');

    return $table.dataTable().fnDraw(oSettings);
    }
    }

    //Grouping Code
    var iColspan = nTrs[0].getElementsByTagName('td').length;
    var sLastGroup = "";
    for ( var i=0 ; i
This discussion has been closed.