Skip to content

Commit

Permalink
fix: Render fluid layout if first row doesnt exist
Browse files Browse the repository at this point in the history
  • Loading branch information
netchampfaris committed Sep 28, 2019
1 parent 1be233d commit 1a9c11e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,16 @@ export default class Style {
if (this.options.layout !== 'fluid') return;

const wrapperWidth = $.style(this.instance.datatableWrapper, 'width');
const firstRowWidth = $.style($('.dt-row', this.bodyScrollable), 'width');
let firstRow = $('.dt-row', this.bodyScrollable);
let firstRowWidth = wrapperWidth;
if (!firstRow) {
let headerRow = $('.dt-row', this.instance.header);
let cellWidths = Array.from(headerRow.children)
.map(cell => cell.offsetWidth);
firstRowWidth = cellWidths.reduce((sum, a) => sum + a, 0);
} else {
firstRowWidth = $.style(firstRow, 'width');
}
const resizableColumns = this.datamanager.getColumns().filter(col => col.resizable);
const deltaWidth = (wrapperWidth - firstRowWidth) / resizableColumns.length;

Expand Down

0 comments on commit 1a9c11e

Please sign in to comment.