Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material-UI Datagrid Pagination is starting on second page when given 1 for page

I'm using Material-UI Datagrid and I'm having an issue with the pagination. I have an api that will accept a page # and a limit like this page=${page}&limit=10`). Once the api is hit and returns 10 rows, I store those 10 rows along with any pagination data that Laravel is sending with paginate. It will look like this.

Data Stored After API Call

What is odd, is this is the right data for the first page but the pagination shows that it is the second page of data.

Here is what data the datagrid has from looking at the components tab in the console Datagrid State

On initial load, this is what happens with the pagination

Initial load of datagrid

This is what the component looks like

Component

like image 382
CookieMonsta89 Avatar asked Nov 14 '25 14:11

CookieMonsta89


1 Answers

That component starts the count from 0. Make sure your DataGrid component is given 0 as page property value :)

Was probably made like that to ease your life when working with arrays.

I used their demo and if you change the value in state to 0 it jumps to page 1.

like image 59
qurquru Avatar answered Nov 17 '25 04:11

qurquru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!