22 Replies
Hi @reactt. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To add server-side pagination in refine, you can use the
useTable
hook with the pagination.mode
set to "server"
. By default, pagination happens on the server side, so you don't need to explicitly set the mode to "server"
.
Here's an example of how to use the useTable
hook with server-side pagination:
Source: useTable - Pagination (https://refine.dev/docs/api-reference/antd/hooks/table/useTable)
Remember that your server should also support pagination by handling the current
and pageSize
values in the request.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------useTable | refine
By using useTable, you can get properties that are compatible with Ant Design
component. All features such as sorting, filtering, and pagination come out of the box. Under the hood it uses useList
for the fetch.<@1048996483648725093> kapa.ai is still learning and improving, please let us how it did by reacting below
xenial-black•16mo ago
@kapa.ai why does the pagination http://localhosy:8000/api/questions?_end=20&_start=10&title_like=
shows this instead of pazesize and currentpage
Let me check the knowledge base for you. One moment! :books:
----------------------
The URL you provided uses
_start
and _end
query parameters for pagination instead of pageSize
and currentPage
. This is a common way to handle pagination in some APIs. In this case, _start
represents the starting index, and _end
represents the ending index of the data you want to fetch.
To handle this type of pagination in refine, you can modify the getList
method in your custom data provider. Here's an example of how to handle _start
and _end
parameters in the getList
method:
Source: Create a data provider from scratch - getList (https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider#create-a-data-provider-from-scratch)
This example assumes that your API returns the total number of records in the x-total-count
header. Make sure to adjust the code according to your API's response format.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------3. Create a data provider from scratch | refine
Introduction
<@1048996483648725093> kapa.ai is still learning and improving, please let us how it did by reacting below
xenial-black•16mo ago
@kapa.ai how do i add pagecount and current in customdata provider
Let me check the knowledge base for you. One moment! :books:
harsh-harlequin•16mo ago
Hello @reactt, thanks for the report! We'll make some changes to rest data provider to make it more smart, please stay tuned!
For now, you can swizzle the data provider and modify as you need
----------------------
To add
pageCount
and current
in a custom data provider, you need to modify the getList
method to handle these parameters. Here's an example of how to handle current
and pageSize
parameters in the getList
method:
Source: Create a data provider from scratch - getList (https://refine.dev/docs/tutorial/understanding-dataprovider/create-dataprovider#create-a-data-provider-from-scratch)
This example assumes that your API returns the total number of records in the x-total-count
header. Make sure to adjust the code according to your API's response format.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------3. Create a data provider from scratch | refine
Introduction
<@1048996483648725093> kapa.ai is still learning and improving, please let us how it did by reacting below
xenial-black•16mo ago
how do i give haspagination true to my useTable @kapa.ai
Let me check the knowledge base for you. One moment! :books:
----------------------
The
useTable
hook in refine handles pagination by default, so you don't need to explicitly set hasPagination
to true
. When you use the useTable
hook, it provides the necessary properties for pagination, which you can pass to the <Table>
component.
Here's an example of how to use the useTable
hook with pagination:
Source: useTable - Pagination (https://refine.dev/docs/api-reference/antd/hooks/table/useTable)
Remember that your server should also support pagination by handling the current
and pageSize
values in the request.
----------------------
Note: you can ask me a follow up question by @ mentioning me again
:speech_balloon:
----------------------useTable | refine
By using useTable, you can get properties that are compatible with Ant Design
component. All features such as sorting, filtering, and pagination come out of the box. Under the hood it uses useList
for the fetch.