From ad0e0b592aba9a41a713ccd96a210f7bc9db7cfb Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 17 Sep 2019 18:59:14 +0530 Subject: [PATCH] fix: Render blank state when rows is 0 --- src/body-renderer.js | 5 +++++ src/style.js | 1 + 2 files changed, 6 insertions(+) diff --git a/src/body-renderer.js b/src/body-renderer.js index b635fc3..1e05aab 100644 --- a/src/body-renderer.js +++ b/src/body-renderer.js @@ -16,6 +16,11 @@ export default class BodyRenderer { this.visibleRows = rows; this.visibleRowIndices = rows.map(row => row.meta.rowIndex); + if (rows.length === 0) { + this.bodyScrollable.innerHTML = this.getNoDataHTML(); + return; + } + const rowViewOrder = this.datamanager.rowViewOrder.map(index => { if (this.visibleRowIndices.includes(index)) { return index; diff --git a/src/style.js b/src/style.js index 97a397c..76bc761 100644 --- a/src/style.js +++ b/src/style.js @@ -297,6 +297,7 @@ export default class Style { setBodyStyle() { const bodyWidth = $.style(this.datatableWrapper, 'width'); const firstRow = $('.dt-row', this.bodyScrollable); + if (!firstRow) return; const rowWidth = $.style(firstRow, 'width'); let width = bodyWidth > rowWidth ? rowWidth : bodyWidth;