fair-rose
fair-rose2w ago

How do I get the total count?

const { dataGridProps, search, filters } = useDataGrid<BaseRecord, HttpError, IShipmentFilterVariables>({
pagination: {
mode: 'server',
},
initialPageSize: 10,
onSearch: (params) => {
const filters: CrudFilters = []
const { q, type, search_term } = params
const { dataGridProps, search, filters } = useDataGrid<BaseRecord, HttpError, IShipmentFilterVariables>({
pagination: {
mode: 'server',
},
initialPageSize: 10,
onSearch: (params) => {
const filters: CrudFilters = []
const { q, type, search_term } = params
` data : [{id: 0, subscription_id: "S-20240613-0000018", member_id: "dong25", member_name: "윤동25",…},…] page : 1 total : 6 `
2 Replies
kapa.ai
kapa.ai2w ago
Hi @florent. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To get the total count of data when using the useDataGrid hook in refine, you can utilize the rowCount property from the dataGridProps returned by the hook. The rowCount value is fetched using the useList hook. Here is how you can access the total count:
const { dataGridProps, search, filters } = useDataGrid<BaseRecord, HttpError, IShipmentFilterVariables>({
pagination: {
mode: 'server',
},
initialPageSize: 10,
onSearch: (params) => {
const filters: CrudFilters = []
const { q, type, search_term } = params
// Add your search logic here
}
});

const totalCount = dataGridProps.rowCount;
console.log("Total Count:", totalCount);
const { dataGridProps, search, filters } = useDataGrid<BaseRecord, HttpError, IShipmentFilterVariables>({
pagination: {
mode: 'server',
},
initialPageSize: 10,
onSearch: (params) => {
const filters: CrudFilters = []
const { q, type, search_term } = params
// Add your search logic here
}
});

const totalCount = dataGridProps.rowCount;
console.log("Total Count:", totalCount);
In this example, dataGridProps.rowCount will give you the total number of data items. For more details, you can refer to the documentation on the rowCount property: - rowCount (https://refine.dev/docs/ui-integrations/material-ui/hooks/use-data-grid#rowcount) If you need to understand how the useList hook works to fetch this data, you can refer to: - useList (https://refine.dev/docs/data/hooks/use-list/) This should help you retrieve and utilize the total count of data in your application. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@1184365192482652173> kapa.ai is still learning and improving, please let us know how it did by reacting below