Pagination datagrid
sorry for my English, our api uses page=x for pagination, by default it returns 20 results per page, so I would like to know how to include this in the datagrid pagination, I imagine you can just change the current with something like "current +1", I just don't know how to do this inside the datagrid
5 Replies
vicious-gold•2y ago
Hi again, which data provider u are using ? I have to ask to understand better.
sensitive-blueOP•2y ago
i using a custom data provider
getList: async ({
resource,
hasPagination = true,
pagination = { current: 1},
filters,
sort,
}) => {
const url =
${apiUrl}/${resource}/
;
const { current = 1} = pagination ?? {};
const queryFilters = generateFilter(filters);
const query: {
page?: number;
page_size?: number;
_sort?: string;
_order?: string;
} = hasPagination
? {
page: current,
}
: {};
and, the api return:
"count": xxx,
"next": "apiXXXXX/?page=2",
"previous": null,
"results": []vicious-gold•2y ago
Your data-provider seems correct. useDataGrid pagination should works out of the box. do you have any errors on console ?
"results": []
is empty. is this the problem ?
I created example with setCurrent
https://codesandbox.io/s/modest-orla-x6ht1o?file=/src/pages/posts/list.tsxsensitive-blueOP•2y ago
this worked, it was exactly what I needed, thank you very much
vicious-gold•2y ago
I'm glad to hear that 🙏 your welcome