Topic: Control what the current page is for MDBDataTable

Jonathan Wambach free asked 4 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?


Piotr Glejzer staff commented 4 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 free commented 4 years ago

That prop worked for me actually! I look forward to the custom checkboxes. TY.


Russell Teesdale free answered 4 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


Russell Teesdale free commented 4 years ago

Quick follow-up: It looks like disableRetreatAfterSorting={true} got this working for me.


Jonathan Wambach free commented 4 years ago

Awesome, thanks so much! This worked for me as well!



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Resolved

Specification of the issue

  • ForumUser: 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