-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[data grid] Is there a way to get the features of footer to the toolbar? #16323
Comments
Hi @ZaidLinkEZ. You would need create a custom toolbar and pass it to the import * as React from "react";
import {
DataGrid,
GridToolbarContainer,
selectedGridRowsCountSelector,
gridTopLevelRowCountSelector,
gridFilteredTopLevelRowCountSelector,
useGridSelector,
useGridApiContext,
} from "@mui/x-data-grid";
import Typography from "@mui/material/Typography";
function CustomToolbar() {
const apiRef = useGridApiContext();
const selectedRows = useGridSelector(apiRef, selectedGridRowsCountSelector);
const totalRows = useGridSelector(apiRef, gridTopLevelRowCountSelector);
const visibleRows = useGridSelector(
apiRef,
gridFilteredTopLevelRowCountSelector
);
return (
<GridToolbarContainer>
<Typography>Selected rows: {selectedRows}</Typography>
<Typography>Total rows: {totalRows}</Typography>
<Typography>Visible rows: {visibleRows}</Typography>
</GridToolbarContainer>
);
}
export default function CustomToolbarGrid() {
return (
<DataGrid
slots={{ toolbar: CustomToolbar }}
/>
);
} Here's a working example in CodeSandbox https://codesandbox.io/p/sandbox/data-grid-footer-data-in-toolbar-h6x9xd. You can find the available state selectors here: https://mui.com/x/react-data-grid/state/#catalog-of-selectors |
Here is an example on how you can add similar stuff to the toolbar as well: #16132 |
@KenanYusuf @michelengelen |
Great to hear @ZaidLinkEZ ... I'll close this then! 👍🏼 |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @ZaidLinkEZ How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey. |
The problem in depth
I wanted to know if the footer details can be brought up to the toolbar, basically like a header of the table beside the toolbar functions. For ex:
Selected Rows :
,Total Rows:
, etc.If not, is it a feature that you are looking forward to bring to the library?
Your environment
`npx @mui/envinfo`
Search keywords: Data grid pro
Order ID: 95670
The text was updated successfully, but these errors were encountered: