-
-
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 column order and dimensions to the portable state #3816
[DataGrid] Add column order and dimensions to the portable state #3816
Conversation
These are the results for the performance tests:
|
23270c4
to
066aed0
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
👋 The migration PR has been merged. Please follow these steps to make sure that the contents are all updated. (Sorry for the inconvenience)
If you are struggle with the steps above, feel free to tag @siriwatknp |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
packages/grid/_modules_/grid/hooks/features/columns/gridColumnsInterfaces.ts
Outdated
Show resolved
Hide resolved
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@@ -316,17 +342,23 @@ export function useGridColumns( | |||
return params; |
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.
It will return params
if columnVisibilityModel
and initialState.columns.columnVisibilityModel
is not present. That means that to use exportState
users need to define these props, even if they are not going to use them. Is this a requirement to use this feature or a bug?
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.
If they don't use columnVisibilityModel
and initialState.columns.columnVisibilityModel
but have this model when exporting.
Then they are probably using GridColDef.hide
And if we let them export / re-import the model, I'm not sure the behavior will be coherent.
I would rather add an explicit note on the column visibility legacy doc to say that state import / export requires to use the new api.
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 problem is not that we don't support restoring the columns when hide
is used. It's not worth to support it since it's a legacy API. The point in my comment was that to able to restore the state with restoreState
the user must set columnVisibilityModel
to some value. Maybe we should improve the condition used to set shouldUseVisibleColumnModel
to assume that we're using the new approach if no column is using hide
. Currently, for it to work when I've no intention of controlling the column visibility I need to pass columnVisibilityModel={}
.
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.
Oh right I forgot to set shouldRegenColumnVisibilityModelFromColumns
to true
when using the legacy method instead of the early return.
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.
Fixed
I added a test to make sure that we don't use the model passed to restoreState
AND don't loose the current hide: true
in state
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Just a general question and feedback. Since we will also have row reordering #4034 does it make sense to include this feature in the beginning or add it later? Also in terms of its API - should the order be per page if there is pagination enabled? |
@DanailH good question |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
@m4theushw if we can finish this one |
Closes #3448 (last missing states)
API
For consistency, I propose to rename
GridState['columns']['all']
intoGridState['columns']['orderedFields']
in v6.The columns selector a not correctly named so we will have a breaking change there anyway.
Examples
Order
Same fields in import and in the columns prop
Missing fields in import
Unmatched fields in import