where to find default pageSize?
in my dataprovider, i did not specify any pagination paramaters, but it is being defaulted to 25, how to change that?
8 Replies
Hi @flankieflew. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The default page size in refine is typically set to 25 for many components and hooks. However, you can easily change this default value. Here's how you can modify the page size:
1. For most hooks like
useTable
, useSimpleList
, and others, you can set the page size in the options:
useTable documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-table/#paginationpagesize)
2. For the useDataGrid
hook (used with Material UI's DataGrid), you can set it like this:
MUI DataGrid with Refine (https://refine.dev/blog/mui-datagrid-refine/#pagination)
3. If you're using the useExport
hook, you can set the page size for data fetching:
useExport documentation (https://refine.dev/docs/core/hooks/utilities/use-export/#pagesize)
4. For custom data providers, you can modify the generatePagination
function to set a different default page size:
Data Provider Interface (https://refine.dev/docs/guides-concepts/data-fetching/#dataprovider-interface)
Remember that changing the default page size in your data provider will affect all components and hooks that use pagination, unless they explicitly set their own page size.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@343691288442306561> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
dependent-tanOP•2d ago
@kapa.ai what if i set mode: "off" will that still default to a pagesize of 25?
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the information provided in the knowledge sources, if you set the pagination mode to "off", the page size will not be applied. Here's what happens when you set
mode: "off"
:
1. Pagination will be disabled entirely. This means that all records will be fetched without any pagination Documentation on pagination.mode (https://refine.dev/docs/data/hooks/use-table/#paginationmode).
2. When pagination is disabled, the pageSize
and setPageSize
values will be undefined
useTable documentation (https://refine.dev/docs/ui-integrations/ant-design/hooks/use-table/#setpagesize).
Here's an example of how you can set the pagination mode to "off":
In this case, the default page size of 25 will not be applied, and all records will be fetched without pagination. The data provider will not limit the results to any specific page size.
It's important to note that disabling pagination might impact performance if you're dealing with large datasets, as it will fetch all records at once.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@343691288442306561> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
dependent-tanOP•2d ago
@kapa.ai i'm actually using useDataGrid like this
but when i put a breakpoint in the getList() method in my dataprovider, pagination is stilll being populated with pageSize of 25
Let me check the knowledge base for you again. One moment! :books:
----------------------
Based on the information provided in the knowledge sources and your specific use case with
useDataGrid
, I can explain why you're still seeing a pageSize
of 25 in your data provider, even with pagination mode set to "off".
The useDataGrid
hook in refine works slightly differently from other hooks when it comes to pagination. According to the useDataGrid documentation (https://refine.dev/docs/ui-integrations/material-ui/hooks/use-data-grid/#return-values-1), the default pageSize
for the DataGrid component is indeed 25, and this is separate from the pagination mode.
Even when you set pagination: { mode: "off" }
, the DataGrid component still maintains its own internal state for things like pageSize
. This is because the Material-UI DataGrid component doesn't have a true "off" mode for pagination - it's always present in some form.
What's happening in your case is:
1. The useDataGrid
hook is setting up the props for the DataGrid component with its default values.
2. These default values include a pageSize
of 25, which is passed to your data provider.
3. Your data provider is receiving this pageSize
value, even though you've set the pagination mode to "off" in the useDataGrid
hook.
To address this, you have a couple of options:
1. You can override the pageSize
in your useDataGrid
call:
2. Alternatively, you can handle this in your data provider by ignoring the pagination parameters when the mode is set to "off".
It's worth noting that as of refine 4.x, there have been some changes to the useDataGrid
hook. If you're using an older version, you might want to consider updating to the latest version for improved functionality and consistency Migration guide (https://refine.dev/docs/migration-guide/3x-to-4x/#usedatagrid-hook).
Remember, even with pagination mode set to "off", the DataGrid will still load all data at once, which could impact performance for large datasets.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@343691288442306561> Kapa.ai is still learning and improving, please let me know how I did by reacting below.