fix: Render fluid layout if first row doesnt exist

This commit is contained in:
Faris Ansari 2019-09-28 14:00:18 +05:30
parent 1be233d054
commit 1a9c11edf0

View File

@ -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;