-
-
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
[data grid] Allow insert rows while using dataSource #16289
Comments
@cherniavskii we had an example some time ago that was handling the "add row to the top" problem, but I cannot find it. Do you recall where we had this? |
Hey @aleksei-a-savitski cc @arminmeh |
@aleksei-a-savitski Some problems that this will solve:
To avoid the cache problem, you will have to call I don't think you need to change the filter to trigger the new request. You can try using https://mui.com/x/api/data-grid/grid-api/#grid-api-prop-unstable_replaceRows to replace rows and adding the new row on top. @cherniavskii @MBilalShafi I couldn't find an easy way to add a new row on top through our API |
hi @cherniavskii @arminmeh in my case new row entries are comming from server and they should be added on top. I haven't tried https://mui.com/x/api/data-grid/grid-api/#grid-api-prop-unstable_replaceRows. In my case it looks like I will have to replace all rows and to do so I will have to store them by myself somewhere. I would be similar to the implementation I have based on 'rows' prop. |
Summary
The new GridDataSource interface simplifies implementation of infinite loading, however it is not possible to prepend new rows to the grid.
Such functiononality would be usefull for implementing table where fresh row entries are comming from websockets in realtime.
Examples
I have created an implementation based on 'rows' prop with full rows update for inifinite loading to show the UX I would like to achive:
https://stackblitz.com/edit/react-jtcqule9?file=Demo.tsx.
And here is my humble attempt to recreate the same using GridDataSource interface:
https://stackblitz.com/edit/react-mdseecwc?file=Demo.tsx.
Currently it is not possible to append rows to the GridDataSource. As a workaround I tried to use a filter with I change manually to trigger the
dataSource.getRows
.I also tried to implement same UX with
apiRef.current.updateRows()
, but it doesn't insert rows into the begining of the grid.Motivation
I'm trying to avoid full rows update while complying to the following requirements:
Search keywords: data grid, update rows, infinite loading, scroll position
The text was updated successfully, but these errors were encountered: