From e0d896bb25c2d88fee0d5fb8105cf3535bf721d7 Mon Sep 17 00:00:00 2001 From: Lim Jonguk Date: Sat, 26 Mar 2022 00:47:20 +0900 Subject: [PATCH] feat: custom feat-custom-pagination --- package.json | 2 ++ src/views/biz/parking/Review.jsx | 5 +++- src/views/form/DataGridPaging.js | 46 ++++++++++++++++++++++++++++++++ src/views/form/Modal/index.js | 2 ++ src/views/form/MuiDataGrid.jsx | 35 +++++++++++++----------- 5 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 src/views/form/DataGridPaging.js diff --git a/package.json b/package.json index cad4742..72e2e77 100755 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "@mui/system": "^5.4.1", "@mui/utils": "^5.4.1", "@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", "@tabler/icons": "^1.53.0", "apexcharts": "^3.33.1", diff --git a/src/views/biz/parking/Review.jsx b/src/views/biz/parking/Review.jsx index 8ab8d68..f2ac347 100644 --- a/src/views/biz/parking/Review.jsx +++ b/src/views/biz/parking/Review.jsx @@ -140,7 +140,10 @@ const ParkingReview = () => { const search = () => { const params = { page: rowsState.page, - size: rowsState.pageSize + size: rowsState.pageSize, + rowLength: 100, + maxColumns: 10, + dataSet: 'Commodity' }; opstBizService.getSimsa680GroupList({ ...params, msYear: selectedYear, msChasu: searchTxt }).then((response) => { diff --git a/src/views/form/DataGridPaging.js b/src/views/form/DataGridPaging.js new file mode 100644 index 0000000..759ec53 --- /dev/null +++ b/src/views/form/DataGridPaging.js @@ -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 ( + ({ 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 ( +
+ +
+ ); +} diff --git a/src/views/form/Modal/index.js b/src/views/form/Modal/index.js index e4766c5..7c3ab5f 100644 --- a/src/views/form/Modal/index.js +++ b/src/views/form/Modal/index.js @@ -6,6 +6,7 @@ import SecondaryAction from 'ui-component/cards/CardSecondaryAction'; import NestedModal from './NestedModal'; import BasicModal from './BasicModal'; import CmmModal from './CmmModal'; +import UseGridSelector from '../DataGridPaging'; // ==============================|| MODAL PAGE ||============================== // @@ -15,6 +16,7 @@ const Modal = () => ( {/* */} + ); diff --git a/src/views/form/MuiDataGrid.jsx b/src/views/form/MuiDataGrid.jsx index 12af1f4..ccaceba 100644 --- a/src/views/form/MuiDataGrid.jsx +++ b/src/views/form/MuiDataGrid.jsx @@ -3,7 +3,8 @@ 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 { Box, Pagination } from '@mui/material'; +import Box from '@mui/material/Box'; +import Pagination from '@mui/material/Pagination'; import { useTheme } from '@mui/material/styles'; import dataGridKoKR from './defaultDataGridLocale'; @@ -42,20 +43,20 @@ const MuiDataGrid = ({ row.rowId} rowCount={totalCount} checkboxSelection={isCheckbox} @@ -79,6 +80,8 @@ const MuiDataGrid = ({ rowsPerPageOptions={[10, 50, 100]} onCellClick={handleCellClick} onSelectionModelChange={handleSelection} + // hideFooter + pagination components={{ CustomPagination }} />