Skip to content

Commit

Permalink
Footer docs example: remove expand button if footer cell is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Mar 14, 2022
1 parent 3ef5b7f commit 7ff929d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src-docs/src/views/datagrid/footer_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,16 @@ const footerCellValues = {
}`,
};

const renderFooterCellValue = ({ columnId }) =>
footerCellValues[columnId] || null;
const RenderFooterCellValue = ({ columnId, setCellProps }) => {
const value = footerCellValues[columnId];

useEffect(() => {
// Turn off the cell expansion button if the footer cell is empty
if (!value) setCellProps({ isExpandable: false });
}, [value, setCellProps]);

return value || null;
};

export default () => {
// Pagination
Expand Down Expand Up @@ -121,7 +129,7 @@ export default () => {
rowCount={raw_data.length}
renderCellValue={RenderCellValue}
renderFooterCellValue={
showFooterRow ? renderFooterCellValue : undefined
showFooterRow ? RenderFooterCellValue : undefined
}
pagination={{
...pagination,
Expand Down

0 comments on commit 7ff929d

Please sign in to comment.