Skip to content

Commit

Permalink
Fix: Colspan calculation was wrong if the table was hidden, or Respon…
Browse files Browse the repository at this point in the history
…sive was used

- FB 292
- Thread 42447
  • Loading branch information
Allan Jardine committed Jun 16, 2017
1 parent 24d09ff commit f1abc53
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
33 changes: 33 additions & 0 deletions examples/initialisation/responsive.xml
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dt-example table-type="html" table-class="display nowrap" order="8">

<css lib="datatables responsive rowgroup"/>
<js lib="jquery datatables responsive rowgroup">
<![CDATA[
$(document).ready(function() {
$('#example').DataTable( {
responsive: true,
order: [[2, 'asc']],
rowGroup: {
dataSrc: 2
}
} );
} );
]]>
</js>

<title lib="RowGroup">Integration with Responsive</title>

<info><![CDATA[
This example shows RowGroup being used with the [Responsive extension](https://datatables.net/extensions/responsive) for DataTables. Responsive allows the table to dynamically grow and shrink as the page is resized, or loaded on browsers with different sizes of display.
As can be seen with this example RowGroup and Responsive interact together exactly as would be expected, combining their respective functionality.
]]></info>

</dt-example>

12 changes: 7 additions & 5 deletions js/dataTables.rowGroup.js
@@ -1,11 +1,11 @@
/*! RowGroup 1.0.0
/*! RowGroup 1.0.1-dev
* ©2017 SpryMedia Ltd - datatables.net/license
*/

/**
* @summary RowGroup
* @description RowGrouping for DataTables
* @version 1.0.0
* @version 1.0.1-dev
* @file dataTables.rowGroup.js
* @author SpryMedia Ltd (www.sprymedia.co.uk)
* @contact datatables.net
Expand Down Expand Up @@ -153,7 +153,7 @@ $.extend( RowGroup.prototype, {
}
} );

dt.on( 'column-visibility.dtrg', function () {
dt.on( 'column-visibility.dt.dtrg responsive-resize.dt.dtrg', function () {
that._adjustColspan();
} );

Expand Down Expand Up @@ -183,7 +183,9 @@ $.extend( RowGroup.prototype, {
*/
_colspan: function ()
{
return $( this.s.dt.columns().header() ).filter(':visible').length;
return this.s.dt.columns().visible().reduce( function (a, b) {
return a + b;
}, 0 );
},

/**
Expand Down Expand Up @@ -321,7 +323,7 @@ RowGroup.defaults = {
};


RowGroup.version = "1.0.0";
RowGroup.version = "1.0.1-dev";


$.fn.dataTable.RowGroup = RowGroup;
Expand Down

0 comments on commit f1abc53

Please sign in to comment.