|
|
|
@ -1,41 +1,22 @@
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
|
|
// material-ui
|
|
|
|
|
// import type { GridColumns } from '@mui/x-data-grid/colDef';
|
|
|
|
|
import { DataGrid, useGridApiRef, gridPageSelector, useGridApiContext, useGridSelector, gridPageCountSelector } from '@mui/x-data-grid';
|
|
|
|
|
import { DataGrid, useGridApiRef } from '@mui/x-data-grid';
|
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import Pagination from '@mui/material/Pagination';
|
|
|
|
|
import { useTheme } from '@mui/material/styles';
|
|
|
|
|
import dataGridKoKR from './defaultDataGridLocale';
|
|
|
|
|
|
|
|
|
|
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)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
import CustomPagination from './CustomPagination';
|
|
|
|
|
|
|
|
|
|
// project imports
|
|
|
|
|
const MuiDataGrid = ({
|
|
|
|
|
isCheckbox = false,
|
|
|
|
|
isHidePagination = false,
|
|
|
|
|
columns,
|
|
|
|
|
rowsState = { page: 0, pageSize: 1000, rows: [] },
|
|
|
|
|
rowsState = { page: 0, pageSize: 10, rows: [] },
|
|
|
|
|
totalCount = 0,
|
|
|
|
|
setRowsState = () => {},
|
|
|
|
|
handleCellClick = () => {},
|
|
|
|
|
handleSelection = () => {}
|
|
|
|
|
}) => {
|
|
|
|
|
// const { columns, rowsState, totalCount, setRowsState } = props;
|
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const apiRef = useGridApiRef();
|
|
|
|
|
|
|
|
|
@ -43,46 +24,57 @@ const MuiDataGrid = ({
|
|
|
|
|
<Box
|
|
|
|
|
sx={{
|
|
|
|
|
height: 670,
|
|
|
|
|
width: '100%'
|
|
|
|
|
// '& .MuiDataGrid-root': {
|
|
|
|
|
// border: 'none',
|
|
|
|
|
// '& .MuiDataGrid-cell': {
|
|
|
|
|
// borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
// },
|
|
|
|
|
// '& .MuiDataGrid-columnsContainer': {
|
|
|
|
|
// color: theme.palette.mode === 'dark' ? 'grey.600' : 'grey.900',
|
|
|
|
|
// borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
// },
|
|
|
|
|
// '& .MuiDataGrid-columnSeparator': {
|
|
|
|
|
// color: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
width: '100%',
|
|
|
|
|
'& .MuiDataGrid-root': {
|
|
|
|
|
border: 'none',
|
|
|
|
|
'& .MuiDataGrid-cell': {
|
|
|
|
|
borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
},
|
|
|
|
|
'& .MuiDataGrid-columnsContainer': {
|
|
|
|
|
color: theme.palette.mode === 'dark' ? 'grey.600' : 'grey.900',
|
|
|
|
|
borderColor: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
},
|
|
|
|
|
'& .MuiDataGrid-columnSeparator': {
|
|
|
|
|
color: theme.palette.mode === 'dark' ? theme.palette.text.primary + 15 : 'grey.200'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'& .MuiPagination-root': {
|
|
|
|
|
'& .MuiPagination-ul': {
|
|
|
|
|
justifyContent: 'center'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<DataGrid
|
|
|
|
|
apiRef={apiRef}
|
|
|
|
|
showCellRightBorder
|
|
|
|
|
showColumnRightBorder
|
|
|
|
|
hideFooterPagination={isHidePagination}
|
|
|
|
|
// apiRef={apiRef}
|
|
|
|
|
// showCellRightBorder
|
|
|
|
|
// showColumnRightBorder
|
|
|
|
|
localeText={dataGridKoKR}
|
|
|
|
|
// paginationMode="server"
|
|
|
|
|
paginationMode="server"
|
|
|
|
|
getRowId={(row) => row.rowId}
|
|
|
|
|
rowCount={totalCount}
|
|
|
|
|
checkboxSelection={isCheckbox}
|
|
|
|
|
disableSelectionOnClick
|
|
|
|
|
// isRowSelectable={(params: any) => params.row.id > 0}
|
|
|
|
|
// rows={tableData}
|
|
|
|
|
columns={columns}
|
|
|
|
|
// pageSize={pageSize}
|
|
|
|
|
{...rowsState}
|
|
|
|
|
onPageChange={(page) => setRowsState((prev) => ({ ...prev, page }))}
|
|
|
|
|
onPageSizeChange={(pageSize) => setRowsState((prev) => ({ ...prev, page: 0, pageSize }))}
|
|
|
|
|
rowsPerPageOptions={[10, 50, 100]}
|
|
|
|
|
onCellClick={handleCellClick}
|
|
|
|
|
onSelectionModelChange={handleSelection}
|
|
|
|
|
// hideFooter
|
|
|
|
|
pagination
|
|
|
|
|
components={{ CustomPagination }}
|
|
|
|
|
// hideFooter
|
|
|
|
|
// hideFooterPagination
|
|
|
|
|
components={{
|
|
|
|
|
Footer: CustomPagination
|
|
|
|
|
}}
|
|
|
|
|
initialState={{
|
|
|
|
|
pagination: {
|
|
|
|
|
pageSize: rowsState.pageSize,
|
|
|
|
|
page: 1
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
@ -90,7 +82,7 @@ const MuiDataGrid = ({
|
|
|
|
|
|
|
|
|
|
MuiDataGrid.propTypes = {
|
|
|
|
|
isCheckbox: PropTypes.bool,
|
|
|
|
|
isHidePagination: PropTypes.bool,
|
|
|
|
|
// isHideFooter: PropTypes.bool,
|
|
|
|
|
columns: PropTypes.array,
|
|
|
|
|
rowsState: PropTypes.any,
|
|
|
|
|
totalCount: PropTypes.number,
|
|
|
|
|