feat: custom feat-custom-pagination

main
Lim Jonguk 3 years ago
parent 3a4caa831e
commit e0d896bb25

@ -20,6 +20,8 @@
"@mui/system": "^5.4.1", "@mui/system": "^5.4.1",
"@mui/utils": "^5.4.1", "@mui/utils": "^5.4.1",
"@mui/x-data-grid": "^5.5.0", "@mui/x-data-grid": "^5.5.0",
"@mui/x-data-grid-generator": "^5.7.0",
"@mui/x-data-grid-pro": "^5.7.0",
"@reduxjs/toolkit": "^1.7.2", "@reduxjs/toolkit": "^1.7.2",
"@tabler/icons": "^1.53.0", "@tabler/icons": "^1.53.0",
"apexcharts": "^3.33.1", "apexcharts": "^3.33.1",

@ -140,7 +140,10 @@ const ParkingReview = () => {
const search = () => { const search = () => {
const params = { const params = {
page: rowsState.page, page: rowsState.page,
size: rowsState.pageSize size: rowsState.pageSize,
rowLength: 100,
maxColumns: 10,
dataSet: 'Commodity'
}; };
opstBizService.getSimsa680GroupList({ ...params, msYear: selectedYear, msChasu: searchTxt }).then((response) => { opstBizService.getSimsa680GroupList({ ...params, msYear: selectedYear, msChasu: searchTxt }).then((response) => {

@ -0,0 +1,46 @@
import * as React from 'react';
import { DataGrid, gridPageSelector, gridPageCountSelector, useGridApiContext, useGridApiRef, useGridSelector } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';
import Pagination from '@mui/material/Pagination';
const Toolbar = () => {
const apiRef = useGridApiContext();
const page = useGridSelector(apiRef, gridPageSelector);
const pageCount = useGridSelector(apiRef, gridPageCountSelector);
return (
<Pagination
sx={(theme) => ({ padding: theme.spacing(1.5, 0) })}
color="primary"
count={pageCount}
page={page + 1}
onChange={(event, value) => apiRef.current.setPage(value - 1)}
/>
);
};
export default function UseGridSelector() {
const { data, loading } = useDemoData({
dataSet: 'Commodity',
rowLength: 100,
maxColumns: 10
});
const apiRef = useGridApiRef();
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
loading={loading}
apiRef={apiRef}
pagination
pageSize={10}
// hideFooter
components={{
Toolbar
}}
/>
</div>
);
}

@ -6,6 +6,7 @@ import SecondaryAction from 'ui-component/cards/CardSecondaryAction';
import NestedModal from './NestedModal'; import NestedModal from './NestedModal';
import BasicModal from './BasicModal'; import BasicModal from './BasicModal';
import CmmModal from './CmmModal'; import CmmModal from './CmmModal';
import UseGridSelector from '../DataGridPaging';
// ==============================|| MODAL PAGE ||============================== // // ==============================|| MODAL PAGE ||============================== //
@ -15,6 +16,7 @@ const Modal = () => (
{/* <SimpleModal /> */} {/* <SimpleModal /> */}
<BasicModal /> <BasicModal />
<NestedModal /> <NestedModal />
<UseGridSelector />
</MainCard> </MainCard>
); );

@ -3,7 +3,8 @@ import PropTypes from 'prop-types';
// material-ui // material-ui
// import type { GridColumns } from '@mui/x-data-grid/colDef'; // import type { GridColumns } from '@mui/x-data-grid/colDef';
import { DataGrid, useGridApiRef, gridPageSelector, useGridApiContext, useGridSelector, gridPageCountSelector } from '@mui/x-data-grid'; import { DataGrid, useGridApiRef, gridPageSelector, useGridApiContext, useGridSelector, gridPageCountSelector } from '@mui/x-data-grid';
import { Box, Pagination } from '@mui/material'; import Box from '@mui/material/Box';
import Pagination from '@mui/material/Pagination';
import { useTheme } from '@mui/material/styles'; import { useTheme } from '@mui/material/styles';
import dataGridKoKR from './defaultDataGridLocale'; import dataGridKoKR from './defaultDataGridLocale';
@ -42,20 +43,20 @@ const MuiDataGrid = ({
<Box <Box
sx={{ sx={{
height: 670, height: 670,
width: '100%', width: '100%'
'& .MuiDataGrid-root': { // '& .MuiDataGrid-root': {
border: 'none', // border: 'none',
'& .MuiDataGrid-cell': { // '& .MuiDataGrid-cell': {
borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200' // borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
}, // },
'& .MuiDataGrid-columnsContainer': { // '& .MuiDataGrid-columnsContainer': {
color: theme.palette.mode === 'dark' ? 'grey.600' : 'grey.900', // color: theme.palette.mode === 'dark' ? 'grey.600' : 'grey.900',
borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200' // borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
}, // },
'& .MuiDataGrid-columnSeparator': { // '& .MuiDataGrid-columnSeparator': {
color: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200' // color: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
} // }
} // }
}} }}
> >
<DataGrid <DataGrid
@ -64,7 +65,7 @@ const MuiDataGrid = ({
showColumnRightBorder showColumnRightBorder
hideFooterPagination={isHidePagination} hideFooterPagination={isHidePagination}
localeText={dataGridKoKR} localeText={dataGridKoKR}
paginationMode="server" // paginationMode="server"
getRowId={(row) => row.rowId} getRowId={(row) => row.rowId}
rowCount={totalCount} rowCount={totalCount}
checkboxSelection={isCheckbox} checkboxSelection={isCheckbox}
@ -79,6 +80,8 @@ const MuiDataGrid = ({
rowsPerPageOptions={[10, 50, 100]} rowsPerPageOptions={[10, 50, 100]}
onCellClick={handleCellClick} onCellClick={handleCellClick}
onSelectionModelChange={handleSelection} onSelectionModelChange={handleSelection}
// hideFooter
pagination
components={{ CustomPagination }} components={{ CustomPagination }}
/> />
</Box> </Box>

Loading…
Cancel
Save