Topic: Control what the current page is for MDBDataTable
Jonathan Wambach asked 5 years ago
I know it is possible to get the current page via onPageChange, but is it possible to go to a specific page in MDBDataTable?
I have a lot going on in my datatable with checkboxes and such. Users will be updating state quite often which triggers the datatable to rerender. This causes the table to go back to page 1, which I do not want. I want to stay at the current page the user is on.
What would be nice is if there was a simple currentPage prop for MDBDataTable. But there doesn't seem to be anything like that. Are there any workarounds?
jimgroome answered 5 years ago
Hi! Found this topic by searching for what I need, and it turns out I need this functionality too!
I have an <MDBDataTable />
with data I'm changing via state. Basically when I reach the last couple of pages, I want to load more data into the table. I have this part working, but as OP mentioned, when new data is loaded in, the user is taken back to page 1 of the table.
It would be ideal if there was a way to stop the table resetting itself when more data is added.
If there's any way we can have this, that would be extremely helpful. J
jimgroome commented 5 years ago
Quick follow-up: It looks like disableRetreatAfterSorting={true}
got this working for me.
Jonathan Wambach commented 5 years ago
Awesome, thanks so much! This worked for me as well!
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: 4.25.6
- Device: Desktop
- Browser: Chrome
- OS: Windows 10
- Provided sample code: No
- Provided link: No
Piotr Glejzer staff commented 5 years ago
It's not possible right now to do that. You can try use prop
disableRetreatAfterSorting
but I think is not working with that. We will add custom checkboxes to our new datatable in the next release.Jonathan Wambach commented 5 years ago
That prop worked for me actually! I look forward to the custom checkboxes. TY.