|
|
@ -1,41 +1,22 @@
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
|
|
|
|
// material-ui
|
|
|
|
// material-ui
|
|
|
|
// import type { GridColumns } from '@mui/x-data-grid/colDef';
|
|
|
|
import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
|
|
|
|
import { DataGrid, useGridApiRef, gridPageSelector, useGridApiContext, useGridSelector, gridPageCountSelector } from '@mui/x-data-grid';
|
|
|
|
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
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';
|
|
|
|
|
|
|
|
import CustomPagination from './CustomPagination';
|
|
|
|
const CustomPagination = () => {
|
|
|
|
|
|
|
|
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)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// project imports
|
|
|
|
// project imports
|
|
|
|
const MuiDataGrid = ({
|
|
|
|
const MuiDataGrid = ({
|
|
|
|
isCheckbox = false,
|
|
|
|
isCheckbox = false,
|
|
|
|
isHidePagination = false,
|
|
|
|
|
|
|
|
columns,
|
|
|
|
columns,
|
|
|
|
rowsState = { page: 0, pageSize: 1000, rows: [] },
|
|
|
|
rowsState = { page: 0, pageSize: 10, rows: [] },
|
|
|
|
totalCount = 0,
|
|
|
|
totalCount = 0,
|
|
|
|
setRowsState = () => {},
|
|
|
|
setRowsState = () => {},
|
|
|
|
handleCellClick = () => {},
|
|
|
|
handleCellClick = () => {},
|
|
|
|
handleSelection = () => {}
|
|
|
|
handleSelection = () => {}
|
|
|
|
}) => {
|
|
|
|
}) => {
|
|
|
|
// const { columns, rowsState, totalCount, setRowsState } = props;
|
|
|
|
|
|
|
|
const theme = useTheme();
|
|
|
|
const theme = useTheme();
|
|
|
|
const apiRef = useGridApiRef();
|
|
|
|
const apiRef = useGridApiRef();
|
|
|
|
|
|
|
|
|
|
|
@ -43,46 +24,57 @@ 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'
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
},
|
|
|
|
|
|
|
|
'& .MuiPagination-root': {
|
|
|
|
|
|
|
|
'& .MuiPagination-ul': {
|
|
|
|
|
|
|
|
justifyContent: 'center'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
<DataGrid
|
|
|
|
<DataGrid
|
|
|
|
apiRef={apiRef}
|
|
|
|
// apiRef={apiRef}
|
|
|
|
showCellRightBorder
|
|
|
|
// showCellRightBorder
|
|
|
|
showColumnRightBorder
|
|
|
|
// showColumnRightBorder
|
|
|
|
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}
|
|
|
|
disableSelectionOnClick
|
|
|
|
disableSelectionOnClick
|
|
|
|
// isRowSelectable={(params: any) => params.row.id > 0}
|
|
|
|
// isRowSelectable={(params: any) => params.row.id > 0}
|
|
|
|
// rows={tableData}
|
|
|
|
|
|
|
|
columns={columns}
|
|
|
|
columns={columns}
|
|
|
|
// pageSize={pageSize}
|
|
|
|
|
|
|
|
{...rowsState}
|
|
|
|
{...rowsState}
|
|
|
|
onPageChange={(page) => setRowsState((prev) => ({ ...prev, page }))}
|
|
|
|
onPageChange={(page) => setRowsState((prev) => ({ ...prev, page }))}
|
|
|
|
onPageSizeChange={(pageSize) => setRowsState((prev) => ({ ...prev, page: 0, pageSize }))}
|
|
|
|
onPageSizeChange={(pageSize) => setRowsState((prev) => ({ ...prev, page: 0, pageSize }))}
|
|
|
|
rowsPerPageOptions={[10, 50, 100]}
|
|
|
|
rowsPerPageOptions={[10, 50, 100]}
|
|
|
|
onCellClick={handleCellClick}
|
|
|
|
onCellClick={handleCellClick}
|
|
|
|
onSelectionModelChange={handleSelection}
|
|
|
|
onSelectionModelChange={handleSelection}
|
|
|
|
// hideFooter
|
|
|
|
|
|
|
|
pagination
|
|
|
|
pagination
|
|
|
|
components={{ CustomPagination }}
|
|
|
|
// hideFooter
|
|
|
|
|
|
|
|
// hideFooterPagination
|
|
|
|
|
|
|
|
components={{
|
|
|
|
|
|
|
|
Footer: CustomPagination
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
initialState={{
|
|
|
|
|
|
|
|
pagination: {
|
|
|
|
|
|
|
|
pageSize: rowsState.pageSize,
|
|
|
|
|
|
|
|
page: 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
);
|
|
|
@ -90,7 +82,7 @@ const MuiDataGrid = ({
|
|
|
|
|
|
|
|
|
|
|
|
MuiDataGrid.propTypes = {
|
|
|
|
MuiDataGrid.propTypes = {
|
|
|
|
isCheckbox: PropTypes.bool,
|
|
|
|
isCheckbox: PropTypes.bool,
|
|
|
|
isHidePagination: PropTypes.bool,
|
|
|
|
// isHideFooter: PropTypes.bool,
|
|
|
|
columns: PropTypes.array,
|
|
|
|
columns: PropTypes.array,
|
|
|
|
rowsState: PropTypes.any,
|
|
|
|
rowsState: PropTypes.any,
|
|
|
|
totalCount: PropTypes.number,
|
|
|
|
totalCount: PropTypes.number,
|
|
|
|