Adding default 'No results' row when sortable table has no rows.

This commit is contained in:
Roland 2024-01-01 17:10:51 -07:00
parent 3ad7b8af00
commit c9f7520604
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93

View file

@ -63,7 +63,14 @@ export class SortableTable extends React.Component {
// Use placeholder while data is null.
let rows = <TableRow><TableCell colSpan={tableHeaders.length}><TextPlaceholder/></TableCell></TableRow>;
if (data !== null) {
rows = data.map(i => <React.Fragment key={i[rowKey]}>{rowFunc(i, this.sortData)}</React.Fragment>);
if (data.length > 0) {
// Convert data to table rows.
rows = data.map(i => <React.Fragment key={i[rowKey]}>{rowFunc(i, this.sortData)}</React.Fragment>);
} else {
// No results in data.
rows = this.props.emptyRow
|| <TableRow><TableCell colSpan={tableHeaders.length}>No results</TableCell></TableRow>;
}
}
return <Table sortable {...this.props.tableProps}>