We are handling our data fetching & paginating manually (through Redux) and passing it to MaterialTable without a promise:
<MaterialTable
...
title='Members'
data={props.members}
/>
However, it appears that MaterialTable gets the total count from this array and doesn't let us specify.
This issue had the same problem, and remoteData was added to allow the user to specify the totalCount, through a Promise.
However we have _zero_ need for using a Promise, and would like to pass totalCount straight to MaterialTable. Additionally a Promise doesn't work for us either, because the data is empty on the first render, and MaterialTable does not re call the Promise on data change.
For example, this could be implemented in multiple ways:
Passing it as a normal prop:
<MaterialTable
...
title='Members'
data={props.members}
totalCount={props.memberCount}
/>
or formatting data as an object, ie the object that Promise is supposed to return:
<MaterialTable
...
title='Members'
data={ { data: props.members, totalCount: props.memberCount, page: 0}
/>
i have the exec same question, if it is possible to give data as array as specified, (
data | Array or func for remote data
) how do i give the total count?
tried also on pagination and didn't work
pagination:{
labelRowsPerPage: this.state.rowsPerPage,
page:page,
totalCount:totalCount
}
Using remote data will also not work with Apollo as it will just go into infinite loop. Prefer to pass totalCount through options.
Hi there,
I was dealing with the same issue and I finally managed to overwrite de Pagination component and handle the events on my Container so I can dispatch redux actions.
I works well so far.
I used this component: https://material-ui.com/api/table-pagination/
and found about component overwriting here: https://material-table.com/#/docs/features/component-overriding
Hope it helps someone.
Cheers
It seems to be resolved by https://github.com/mbrn/material-table/pull/795.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You can reopen it if it required.
Can you help me with how to use totalCount with remote data?
It seems to be resolved by #795.
Yes, it works, but not described in the documentation.
Just specify simultaneously 2 props:
<MaterialTable
...
data={data}
page={page}
totalCount={count}
...
/>
Most helpful comment
Hi there,
I was dealing with the same issue and I finally managed to overwrite de Pagination component and handle the events on my Container so I can dispatch redux actions.
I works well so far.
I used this component: https://material-ui.com/api/table-pagination/
and found about component overwriting here: https://material-table.com/#/docs/features/component-overriding
Hope it helps someone.
Cheers