gregnb / gregnb/mui-datatables
Page option not working on init
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 906
- PR merge metrics
- No merged PRs in 30d
Description
Hi, I'm saving the table state globally, filters/sort/search param and I want to save the current page. So when I go to some route and get back to route where the table is, the saved table state is used when initializing table and all saved data works except the page option.
This is how I load up the save table state.
```
const { orders: tableState } = state;
const options = {
onTableChange: (action, newTableState) => {
switch (action) {
case 'changeRowsPerPage':
case 'changePage':
case 'sort':
case 'filterChange':
case 'resetFilters':
case 'search':
setState(currentState => ({
tables: {
...currentState.tables,
orders: newTableState,
},
}));
break;
case 'propsUpdate':
case 'columnViewChange':
default:
}
},
rowsPerPage: tableState ? tableState.rowsPerPage : ROWS_PER_PAGE,
page: tableState ? tableState.page : 0,
searchText: tableState ? tableState.searchText : null,
sortOrder: tableState ? tableState.sortOrder : null,
};
```
And then I pass the options to table. Is there a reason why only the page option is not loading on init? The `tableState.page` is loaded fine and has a value greater then 0(when changing pages) and is of type number.
Thanks
I'm using 3.7.1 version of mui-datatable
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.