How to disable Material UI DataGrid go to next page button while loading the API - reactjs

This code is regarding Material UI Datagrid
I need to disable the Go to next page button while loading the API
<DataGrid
autoHeight
getRowHeight={getRowHeight}
rows={rows}
columns={columns}
page={page - 1}
rowCount={total}
rowsPerPageOptions={rowsPerPage}
pagination
paginationMode='server'
pageSize={pageSize}
getRowClassName={(params) => getRowClassName(params)}
onPageChange={(newPage) => handelPageChange(newPage)}
loading={isLoading}
// disableNextPage={isLoading}
onPageSizeChange={(newPageSize) =>
setAssetList((prveState) => ({
...prveState,
pageSize: newPageSize,
}))
}
/>

I have used this prop it has been resolved
hideFooterPagination={isLoading}

Related

How do I customize the MUI DataGrid footer components?

I am using the MUI V5 DataGrid component in my App and I want to customize the Footer component on the datagrid component but can't find any docs on how to go about it. This is the current default footer:
I want to achieve something resembling this:
Is there a way to reorganize the individual components and customize the styling as such? Any help is highly appreciated.
this sample code you can use for a custom footer in data grid MUI v5
first, you write your pagination component with full logic when the client clicked on the page, like this :
const RoundedPagination = () => {
return (
<Stack spacing={2}>
<Pagination
shape="rounded" page={page + 1} onChange={handleChange} count={props.numberOfPages}
renderItem={(item) => (
<PaginationItem
sx={{
color: 'main.0',
}}
components={{previous: ArrowRightRoundedIcon, next: ArrowLeftRoundedIcon}}
{...item}
/>
)}
/>
</Stack>
)
}
then you use this component in data grid like this :
<Grid container item justifyContent={'center'} alignItems={'center'} md={12}>
<DataGrid
page={page}
rows={props.dataGridValue.ROW}
columns={props.dataGridValue.COLUMNS}
autoHeight
headerHeight={52}
rowsPerPageOptions={[10]}
disableColumnMenu
Pagination
hideFooterSelectedRowCount
components={{
Pagination: RoundedPagination,
}}
/>
</Grid>
hope you get your answer good luck ;)

Material UI Datagrid custom checkbox behavior

I have a datagrid table with checkboxSelection enabled. This means, the checkbox is always visible, whenever the data is available or not.
I am trying to render a spinner while the data is being fetch, and afterwards the checkbox itself. So I tried:
<Table
loading={loading}
pagination
checkboxSelection
isRowSelectable={isRowSelectable as SclTableProps['isRowSelectable']}
columns={columns as SclTableProps['columns']}
rows={rows}
selectionModel={selectionModel}
components={{
BaseCheckbox: (a) => loading ? <>loading...</> : (
<Checkbox checked={a.checked} /> // <-- this is imported from '#material-ui'
),
}}
/>
Although, visual-wise it worked, the checkbox lost it's functionality.
So, I tried to rebuild the selection
BaseCheckbox: (a) => loading ? <>loading...</> : (
<Checkbox
onClick={(params) => {
//do something
}}
checked={a.checked}
/>
),
But I am not able to identify which row in the table I clicked (via row id for example).
So how should I proceed to either have the default features and selections or at least be able to grab the row data that is being selected.

Material UI -Data Grid Custom Pagination

I am trying to use the custom pagination from here
https://material-ui.com/components/data-grid/style/#custom-theme
however the pagination seems broken itself? Can anyone guide why the pagination is not working and what needs to be done, so that i can implement it?
When I click on page 2, and the click on Page 1, its not working.
I had to update the pagination to
<Pagination
color="primary"
showFirstButton
showLastButton
page={state.pagination.page + 1}
count={state.pagination.pageCount}
// #ts-expect-error
renderItem={props2 => <PaginationItem {...props2} disableRipple />}
onChange={(event, value) => apiRef.current.setPage(value-1)}
/>
)

How to close Filter dialog in MUI datatable

I am using MUI datatable in my react project. I used serverside filtering and customFilterDialogFooter where I include following code in options which is passed in mui-datatables. When I click on Apply Filters button, I fetched data from server using my filtering criteria which is completely fine but Filter window is not closed. Is there any way to close filter window?
customFilterDialogFooter: filterList => {
return (
<div style={{marginTop: '40px'}}>
<Button variant="contained" onClick={() => {
handleFilterSubmit(filterList)
}}>Apply Filters</Button>
</div>
);
}
Filter dialog is closed on the version mui-datatables": "3.0.0"
<MUIDataTable
data={data}
columns={COLUMNS}
options={{ viewColumns: false }}
/>

How to remove the overlay loader from material table?

How can I remove the overlay loader completely from the table?
(Table used: https://github.com/mbrn/material-table)
You can use OverlayLoading field to remove the overlay loader style of material-table.
<MaterialTable
columns={columns}
data={...}
components={{
OverlayLoading: props => (<div></div>)
}}
/>
You can change loadingType to linear in options:
<MaterialTable
columns={columns}
data={...}
options={{
loadingType: 'linear'
}}
/>
You can override Overlay loading component like this,
<MaterialTable
columns={columns}
data={...}
components={{
OverlayLoading: () => <div />
}}
/>

Resources