When paginating, it's essential to be able to easily configure the
pageSize
(specified by the
defaultLimit
prop) and the
defaultSkip
. In addition, you can also configure
pageSizes
, which controls the page sizes available in the pagination toolbar so the user can modify the page size by choosing a different value.
defaultLimit
and
defaultSkip
are
uncontrolled props - as a result, you don't have to update them to get pagination working as expected. This is the easiest way to get up & running quickly with
<DataGrid />
pagination.
On the other hand, the
<DataGrid />
also offers the
controlled versions of those props:
limit
and
skip
. To make pagination work with those controlled props, make sure you update them using
onLimitChange
and
onSkipChange
.
To prove how you can have full control over the pagination with
controlled limit
and
skip
, take a look at the example below.
As seen in the example above, with the controlled
limit
and
skip
, the
dataSource
function is automatically called when any of those values change, so it's rather easy to implement custom pagination logic - if the current configuration props are not enough. At any time you can use
renderPaginationToolbar
to render a custom component for pagination instead of the default
PaginationToolbar
.