Hide table footer when all groups are empty

This commit is contained in:
Anders Borch
2023-04-12 19:27:29 +02:00
parent 7887e724d5
commit 5619078abd

View File

@ -70,6 +70,10 @@ function Table({ data, columns, viewName, viewIcon }: OwnProps) {
</tr> </tr>
))} ))}
</tbody> </tbody>
{table
.getFooterGroups()
.flatMap((group) => group.headers)
.filter((header) => !!header.column.columnDef.footer).length > 0 && (
<tfoot> <tfoot>
{table.getFooterGroups().map((footerGroup) => ( {table.getFooterGroups().map((footerGroup) => (
<tr key={footerGroup.id}> <tr key={footerGroup.id}>
@ -86,7 +90,7 @@ function Table({ data, columns, viewName, viewIcon }: OwnProps) {
</tr> </tr>
))} ))}
</tfoot> </tfoot>
</table> )}
</StyledTable> </StyledTable>
</div> </div>
); );