-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Add resetPageOnSortFilter
prop that resets the page after sorting/filtering
#16450
Conversation
packages/x-data-grid/src/hooks/features/pagination/useGridPaginationModel.ts
Show resolved
Hide resolved
resetPageAfterSortingOrFiltering
prop that resets the page after sorting/filteringresetPageOnSortFilter
prop that resets the page after sorting/filtering
20ffdf4
to
a3ad812
Compare
@@ -8,6 +8,10 @@ The example below demonstrates how to achieve server-side filtering. | |||
|
|||
{{"demo": "ServerFilterGrid.js", "bg": "inline"}} | |||
|
|||
:::info | |||
Combine server-side filtering with [Server-side sorting](/x/react-data-grid/sorting/#server-side-sorting) and [Server-side pagination](/x/react-data-grid/pagination/#server-side-pagination) to avoid fetching more data than needed, since you already process the data outside of the Data Grid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following text would be more relatable for me. Also, I'd like to keep it as warning, as to me this call-out is not for an "improved" but a "proper" implementation.
Combine server-side filtering with [Server-side sorting](/x/react-data-grid/sorting/#server-side-sorting) and [Server-side pagination](/x/react-data-grid/pagination/#server-side-pagination) to avoid fetching more data than needed, since you already process the data outside of the Data Grid. | |
To have a proper server-side binding, you should combine server-side filtering with [Server-side sorting](/x/react-data-grid/sorting/#server-side-sorting) and [Server-side pagination](/x/react-data-grid/pagination/#server-side-pagination). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having the text updated would warrant IMO an update to a warning
callout. As I am still more in favor of keeping it as info I would also like to keep the text as is.
packages/x-data-grid/src/hooks/features/pagination/useGridPaginationModel.ts
Outdated
Show resolved
Hide resolved
6954442
to
e1bbb5d
Compare
Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com> Co-authored-by: Sam Sycamore <71297412+mapache-salvaje@users.noreply.github.com> Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com>
Co-authored-by: Sam Sycamore <71297412+mapache-salvaje@users.noreply.github.com> Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
packages/x-data-grid/src/hooks/features/pagination/useGridPaginationModel.ts
Outdated
Show resolved
Hide resolved
expect(apiRef.current!.state.pagination.paginationModel.page).to.equal(1); | ||
|
||
act(() => { | ||
apiRef.current?.sortColumn('id', 'desc'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use !
throughout instead of ?
?
apiRef.current?.sortColumn('id', 'desc'); | |
apiRef.current!.sortColumn('id', 'desc'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to do this for the whole repo in another PR
Cherry-pick PRs will be created targeting branches: v7.x |
…r sorting/filtering (#16450) Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com> Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com> Co-authored-by: Sam Sycamore <71297412+mapache-salvaje@users.noreply.github.com>
…r sorting/filtering (#16450) Signed-off-by: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com> Co-authored-by: Bilal Shafi <bilalshafidev@gmail.com> Co-authored-by: Sam Sycamore <71297412+mapache-salvaje@users.noreply.github.com>
Realted to #15378
It is a first PR that will be cherry-picked to v7
#16447 will remove the prop for v8 and include migration notes
Preview
https://deploy-preview-16450--material-ui-x.netlify.app/x/react-data-grid/sorting/#reset-page-on-sorting
https://deploy-preview-16450--material-ui-x.netlify.app/x/react-data-grid/filtering/#reset-page-on-filtering