-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Migration of the paginaton (#224)
- Loading branch information
1 parent
dbdcad2
commit 4d15119
Showing
12 changed files
with
152 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Pagination | ||
className={classes.root} | ||
color="primary" | ||
page={paginationProps.page} | ||
count={paginationProps.pageCount} | ||
onChange={(event, value) => 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 ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid | ||
pagination | ||
pageSize={5} | ||
components={{ | ||
pagination: CustomPagination, | ||
}} | ||
{...data} | ||
/> | ||
</div> | ||
); | ||
} |
55 changes: 55 additions & 0 deletions
55
docs/src/pages/components/data-grid/rendering/CustomPaginationGrid.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) => void; | ||
}; | ||
} | ||
|
||
function CustomPagination(props: CustomPaginationProps) { | ||
const { paginationProps } = props; | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<Pagination | ||
className={classes.root} | ||
color="primary" | ||
page={paginationProps.page} | ||
count={paginationProps.pageCount} | ||
onChange={(event, value) => paginationProps.setPage(value)} | ||
/> | ||
); | ||
} | ||
|
||
export default function CustomPaginationGrid() { | ||
const { data } = useDemoData({ | ||
dataSet: 'Commodity', | ||
rowLength: 100, | ||
maxColumns: 6, | ||
}); | ||
|
||
return ( | ||
<div style={{ height: 400, width: '100%' }}> | ||
<DataGrid | ||
pagination | ||
pageSize={5} | ||
components={{ | ||
pagination: CustomPagination, | ||
}} | ||
{...data} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters