gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.71k stars 932 forks source link

Start with page 0 on new result set #1166

Open crudnick opened 4 years ago

crudnick commented 4 years ago

I'm using the data tables with server side filtering, to be able to adapt the result set. When i go through the pages (client side pagination is enabled) and decide to tweak my server side search and get a new result set, the datatable stays on the page number i viewed before.

Expected Behavior

The datatable should start with page 0 when it gets a new result set. (i set the option page=0 already)

Your Environment

Tech Version
Material-UI 4.6.0
MUI-datatables 2.13.3
React 16.11.0
browser Chrome latest
wdh2100 commented 4 years ago

https://github.com/gregnb/mui-datatables#options

const options = { page: 0, ...otherOptions, };

pr-lawrence commented 4 years ago

+1

crudnick commented 4 years ago

Unfortunately this doesn’t work for me. I tried that option already (as written above) Since I’m updating the result set from outside, it is a different use case. Here it stays on the page I have been before.

On 9. February 2020 at 07:32:05, Woo Dohyeong (notifications@github.com) wrote:

https://github.com/gregnb/mui-datatables#options

const options = { page: 0, ...otherOptions, };

wdh2100 commented 4 years ago

i think... try Use the status (page)

const [myPage, setMyPage] = useState(0);

const options = { page: myPage, ...otherOptions, };

Balyasov commented 4 years ago

I've faced with same behavior, options doesn't update after table has been initialized. So I change key for table for evey new response received from server.

<MUIDataTable 
  key={`table_${pagination.currentPage}`} 
  options={ page: pagination.currentPage - 1 } 
/>