Stop showing empty table when there are no records (#790)
This commit is contained in:
parent
53c616b747
commit
4d9727203b
|
|
@ -95,6 +95,8 @@ const Table = (props: TableProps) => {
|
||||||
useFlexLayout,
|
useFlexLayout,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (rows.length === 0 || headerGroups.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledTableWrapped
|
<StyledTableWrapped
|
||||||
width={200}
|
width={200}
|
||||||
|
|
@ -126,7 +128,6 @@ const Table = (props: TableProps) => {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{headerGroups.length === 0 && renderEmptyRows(1, 2)}
|
|
||||||
<div {...getTableBodyProps()} className="tbody">
|
<div {...getTableBodyProps()} className="tbody">
|
||||||
{rows.map((row: any, index: number) => {
|
{rows.map((row: any, index: number) => {
|
||||||
prepareRow(row);
|
prepareRow(row);
|
||||||
|
|
@ -150,7 +151,6 @@ const Table = (props: TableProps) => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{rows.length === 0 && renderEmptyRows(1, 2)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -158,38 +158,4 @@ const Table = (props: TableProps) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderEmptyRows = (rowCount: number, columns: number) => {
|
|
||||||
const rows: string[] = new Array(rowCount).fill("");
|
|
||||||
const tableColumns = new Array(columns).fill("");
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
{rows.map((row: string, index: number) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="tr"
|
|
||||||
key={index}
|
|
||||||
style={{
|
|
||||||
display: "flex",
|
|
||||||
flex: "1 0 auto",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{tableColumns.map((column: any, colIndex: number) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={colIndex}
|
|
||||||
className="td"
|
|
||||||
style={{
|
|
||||||
boxSizing: "border-box",
|
|
||||||
flex: "1 0 auto",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Table;
|
export default Table;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user