diff --git a/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.js b/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.js index ea6d6ed18e9f8..860d4760fc60f 100644 --- a/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.js +++ b/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.js @@ -10,13 +10,8 @@ export default function AutoPaginationGrid() { }); return ( -
- +
+
); } diff --git a/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.tsx b/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.tsx index ea6d6ed18e9f8..860d4760fc60f 100644 --- a/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.tsx +++ b/docs/src/pages/components/data-grid/pagination/AutoPaginationGrid.tsx @@ -10,13 +10,8 @@ export default function AutoPaginationGrid() { }); return ( -
- +
+
); } diff --git a/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.js b/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.js index 003f2c2eccb58..fed2b66fb80cc 100644 --- a/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.js +++ b/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.js @@ -10,8 +10,8 @@ export default function BasisPaginationGrid() { }); return ( -
- +
+
); } diff --git a/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.tsx b/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.tsx index 003f2c2eccb58..fed2b66fb80cc 100644 --- a/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.tsx +++ b/docs/src/pages/components/data-grid/pagination/BasicPaginationGrid.tsx @@ -10,8 +10,8 @@ export default function BasisPaginationGrid() { }); return ( -
- +
+
); } diff --git a/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.js b/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.js index 964947f71a764..2b713aa3e6276 100644 --- a/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.js +++ b/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.js @@ -12,7 +12,7 @@ export default function ControlledPaginationGrid() { const [page, setPage] = React.useState(1); return ( -
+
{ @@ -20,8 +20,7 @@ export default function ControlledPaginationGrid() { }} pageSize={5} pagination - rows={data.rows} - columns={data.columns} + {...data} />
); diff --git a/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.tsx b/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.tsx index 7383ea172305e..cd94b1a80298e 100644 --- a/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.tsx +++ b/docs/src/pages/components/data-grid/pagination/ControlledPaginationGrid.tsx @@ -11,7 +11,7 @@ export default function ControlledPaginationGrid() { const [page, setPage] = React.useState(1); return ( -
+
{ @@ -19,8 +19,7 @@ export default function ControlledPaginationGrid() { }} pageSize={5} pagination - rows={data.rows} - columns={data.columns} + {...data} />
); diff --git a/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.js b/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.js index 7a1ca719ca4ff..1aeb6f5da2c09 100644 --- a/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.js +++ b/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.js @@ -10,13 +10,12 @@ export default function SizePaginationGrid() { }); return ( -
+
); diff --git a/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.tsx b/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.tsx index 7a1ca719ca4ff..1aeb6f5da2c09 100644 --- a/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.tsx +++ b/docs/src/pages/components/data-grid/pagination/SizePaginationGrid.tsx @@ -10,13 +10,12 @@ export default function SizePaginationGrid() { }); return ( -
+
); diff --git a/docs/src/pages/components/data-grid/pagination/pagination.md b/docs/src/pages/components/data-grid/pagination/pagination.md index 86c5094b74400..2739ecdd03bba 100644 --- a/docs/src/pages/components/data-grid/pagination/pagination.md +++ b/docs/src/pages/components/data-grid/pagination/pagination.md @@ -7,8 +7,9 @@ components: DataGrid, XGrid

Through paging, a segment of data can be viewed from the assigned data source.

-By default, the Grid displays all the rows with infinite scrolling (and virtualization). -Set the `pagination` prop to enable the pagination feature. +By default, the MIT `DataGrid` displays the rows with pagination, and up to 100 rows per page. + +On the other hand, the commercial `XGrid` component displays, by default, all the rows with infinite scrolling (and virtualization) and without the 100 rows per page limitation. You need to set the `pagination` prop to enable the pagination feature in such a case. ## Basic example @@ -34,6 +35,12 @@ By default, this feature is off. {{"demo": "pages/components/data-grid/pagination/AutoPaginationGrid.js"}} +## Custom pagination component + +Head to the [rendering section](/components/data-grid/rendering/#pagination) of the documentation for customizing the pagination component. + +## Server-side pagination + - https://ej2.syncfusion.com/react/demos/#/material/grid/paging - https://devexpress.github.io/devextreme-reactive/react/grid/docs/guides/paging/ - https://www.telerik.com/kendo-react-ui/components/grid/paging/ diff --git a/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.js b/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.js new file mode 100644 index 0000000000000..5c627d7ba3e89 --- /dev/null +++ b/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.js @@ -0,0 +1,56 @@ +import * as React from 'react'; +import PropTypes from 'prop-types'; +import { makeStyles } from '@material-ui/core/styles'; +import { DataGrid } from '@material-ui/data-grid'; +import { useDemoData } from '@material-ui/x-grid-data-generator'; +import Pagination from '@material-ui/lab/Pagination'; + +const useStyles = makeStyles({ + root: { + display: 'flex', + }, +}); + +function CustomPagination(props) { + const { paginationProps } = props; + const classes = useStyles(); + + return ( + paginationProps.setPage(value)} + /> + ); +} + +CustomPagination.propTypes = { + paginationProps: PropTypes.shape({ + page: PropTypes.number.isRequired, + pageCount: PropTypes.number.isRequired, + setPage: PropTypes.func.isRequired, + }).isRequired, +}; + +export default function CustomPaginationGrid() { + const { data } = useDemoData({ + dataSet: 'Commodity', + rowLength: 100, + maxColumns: 6, + }); + + return ( +
+ +
+ ); +} diff --git a/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.tsx b/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.tsx new file mode 100644 index 0000000000000..8b078ba85ee8f --- /dev/null +++ b/docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.tsx @@ -0,0 +1,55 @@ +import * as React from 'react'; +import { makeStyles } from '@material-ui/core/styles'; +import { DataGrid } from '@material-ui/data-grid'; +import { useDemoData } from '@material-ui/x-grid-data-generator'; +import Pagination from '@material-ui/lab/Pagination'; + +const useStyles = makeStyles({ + root: { + display: 'flex', + }, +}); + +interface CustomPaginationProps { + paginationProps: { + page: number; + pageCount: number; + setPage: (newPage: number) => {}; + }; +} + +function CustomPagination(props: CustomPaginationProps) { + const { paginationProps } = props; + const classes = useStyles(); + + return ( + paginationProps.setPage(value)} + /> + ); +} + +export default function CustomPaginationGrid() { + const { data } = useDemoData({ + dataSet: 'Commodity', + rowLength: 100, + maxColumns: 6, + }); + + return ( +
+ +
+ ); +} diff --git a/docs/src/pages/components/data-grid/rendering/rendering.md b/docs/src/pages/components/data-grid/rendering/rendering.md index 81df7faafedf7..4416b288b4351 100644 --- a/docs/src/pages/components/data-grid/rendering/rendering.md +++ b/docs/src/pages/components/data-grid/rendering/rendering.md @@ -6,3 +6,19 @@ components: DataGrid, XGrid # Data Grid - Rendering

Start

+ +## Components + +As part of our customization API, the Grid allows to replace and override the following components: + +- `header`: The component rendered above the column header bar. +- `loadingOverlay`: The component rendered when the loading react prop is set to true. +- `noRowsOverlay`: The component rendered when the rows react prop is empty or []. +- `footer` - The component rendered below the viewport. +- `pagination`: The component rendered for the pagination feature. + +### Pagination + +By default, the pagination uses the [TablePagination](/components/pagination/#table-pagination) component that is optimized for handling tabular data. This demo replaces it with the [Pagination](/components/pagination/) component. + +{{"demo": "pages/components/data-grid/rendering/CustomPaginationGrid.js"}}