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 methods to import and export the state #3593
[DataGrid] Add methods to import and export the state #3593
Conversation
These are the results for the performance tests:
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I support the @benjimac93 notion of having the order of columns saved as the part of initial state as well as the width of the individual column. It would be a very useful feature for our end users. |
Understood it's not in scope for the initial release of this feature. Is there a rough timeline for when it will be in scope in a future release though? Trying to decide if we use MUI Pro or Premium for our product rebuild or if we need to explore other options |
@benjimac93 we could probably try to release this feature by the end of Q1 as it is not a major peace of work. |
I can work with that. Component is awesome as an aside ! |
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.
Will this be done in this PR?
packages/grid/x-data-grid-pro/src/tests/statePersistence.DataGridPro.test.tsx
Outdated
Show resolved
Hide resolved
onSelect={handleSetActiveView} | ||
/> | ||
))} | ||
<Divider /> |
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.
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 did not finalize this demo, as I wanted feedbacks about the global idea before spending to much times on the details.
But I agree that it is not 100% clean right now 👍
Yes I think it's better to do it, I will add it today or tomorrow |
@m4theushw I added the default value stripping |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
@m4theushw I can merge this one without the doc visible and start working on the columns size and order yes. |
@flaviendelangle Great work and so happy this is merged now! I was wondering why is the scrollPosition not part of the state? and is there a way to set an initialScrollPosition prop for the grid just like there is an initialState prop? |
The scroll position is not on our internal state at all because it is too volatile. What is your use-case exactly ? Would you like to scroll to a position in pixel or to a given row on mount ? |
Closes #820
https://deploy-preview-3593--material-ui-x.netlify.app/components/data-grid/state/#save-and-restore-the-state
Public API
Internals
Each hook with an initial state must also register two pre-processors:
exportState
which takes aGridInitialState
and add the initial state from this hook to itrestoreState
which takes theGridInitialState
to restore and updates the state accordingly.This method can also return a callback that will be ran after all the initial states are restored. This can be usefull to apply the sorting / filtering for instance.
I don't use directly
setFilterModel
,setPageSize
, etc... to avoid multipleforceUpdates
which causes a lot of re-renders.