-
-
Notifications
You must be signed in to change notification settings - Fork 412
Fix/default editable grid #3526
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
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| export function parseColumns(columns: SerializableGridColumns): GridColDef[] { | ||
| export function parseColumns(columns: SerializableGridColumns, isEditable?: boolean): GridColDef[] { |
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.
parseColumns acts as a conversion between "serializable columns" and "X grid columns". It's being reused across the codebase for this purpose. I prefer to keep this function single purpose.
How do you feel about solving this downstream instead? Where we iterate a second time to create the rendered columns:
https://github.com/mui/mui-toolpad/blob/02cc9a97b76098d51651eb48cf10c12ccdc7c8fe/packages/toolpad-studio-components/src/DataGrid.tsx#L1264-L1279
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.
@Janpot , say we're having id column it shouldn't be editable at all right, should I move the isIdColumn logic to this function?
If we update the editable here id column may probably get override right?
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.
How about we only set isEditable if it isn't already defined? And remove isEditable: true from the baseColumn in parseColumns.
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.
Yea, that's a good approach. Will update accordingly.
2797c76 to
825b970
Compare
|
@Janpot I have updated the changes you suggested, can you please verify. |
| return column; | ||
| } | ||
|
|
||
| column.editable = isRowUpdateModelAvailable; |
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 think we should avoid mutating items in .map. Perhaps something like the following would work?
return column.editable === undefined ? { ...column, editable: isRowUpdateModelAvailable } : column;
Can you look into why the tests fail? |
Closes #3524