Introduction
ProTable
is built up on Mantine React Table. In principle we don’t change compoent behavior, only
with some style changes. So you can refer its documentation directly.
Changes
Pagination
Refer to Mantine React Table Pagination. Basically, you can directly use the props listed on the documentation
excepts manualPagination
, paginationDisplayMode
and positionPagination
Name | Type | Description | Usage |
---|---|---|---|
mantinePaginationProps | PaginationProps & { rowsPerPageOptions?: string[], showRowsPerPage?: boolean; } | props for pagination | deprecated , please use pagination |
paginationDisplayMode | ’default’, ‘pages’, ‘custom’ | deprecated | |
positionPagination | ’bottom’, ‘top’, ‘both’ | ||
pagination | PaginationProps & { rowsPerPageOptions?: ComboboxData[], showRowsPerPage?: boolean; showTotal?: boolean, localization?: { total?: string }, wrapperProps?: FlexProps } | props for pagination | |
pagination.value | number | current page of pagination | deprecated , please use state.pagination.pageIndex |
pagination.total | number | current page size of pagination | deprecated , please use state.pagination.rowCount , table will calculate size internally |
pagination
vs state.pagination
In general, use the pagintaion
to control the style of paginations, such as layout, show or hide total pages. Use state.pagination
to control the state of pagination such as changing pageIndex or pageSize
Usage
- For client side pagination:
const table = useProTable({
columns,
data,
enablePagination: true,
})
<ProTable table={table} />
// or
<ProTable data={columns} data={data} enabolePagination />
- For manual or server-side pagination
//store pagination state in your own state
const [pagination, setPagination] = useState({
pageIndex: 0,
pageSize: 5 //customize the default page size
})
const table = useProTable({
columns,
data,
manualPagination: true, // set this true
onPaginationChange: setPagination,
rowCount: data.meta.totalDBRowCount // you can tell the pagination how many rows there are in your back-end data,
enablePagination: true,
state: { pagination }, //pass the pagination state to the table
})
<ProTable table={table} />
- For pagination UI
const table = useProTable({
columns,
data,
enablePagination: true,
pagination: {
wrapperProps: {}, // Props for pagination container
rowsPerPageOptions: [] // configure rows per page options
showRowsPerPage: true, // determine whether shows rows per page
showTotal: true, // determine whether shows total
localization: { // i18n
total: 'Total' // default is 'Total:`
}
}
})
<ProTable table={table} />