From c9f7520604154fb24c29696298ad45cb60cf4ae8 Mon Sep 17 00:00:00 2001 From: Roland Date: Mon, 1 Jan 2024 17:10:51 -0700 Subject: [PATCH] Adding default 'No results' row when sortable table has no rows. --- app/src/components/SortableTable.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/components/SortableTable.js b/app/src/components/SortableTable.js index 4757035d..0c238f29 100644 --- a/app/src/components/SortableTable.js +++ b/app/src/components/SortableTable.js @@ -63,7 +63,14 @@ export class SortableTable extends React.Component { // Use placeholder while data is null. let rows = ; if (data !== null) { - rows = data.map(i => {rowFunc(i, this.sortData)}); + if (data.length > 0) { + // Convert data to table rows. + rows = data.map(i => {rowFunc(i, this.sortData)}); + } else { + // No results in data. + rows = this.props.emptyRow + || No results; + } } return