Skip to content

Conversation

b4s36t4
Copy link
Contributor

@b4s36t4 b4s36t4 commented May 6, 2024

Closes #3524

  • I've read and followed the contributing guide on how to create great pull requests.
  • I've updated the relevant documentation for any new or updated feature.
  • I've linked relevant GitHub issue with "Closes #".
  • I've added a visual demonstration in the form of a screenshot or video.

}

export function parseColumns(columns: SerializableGridColumns): GridColDef[] {
export function parseColumns(columns: SerializableGridColumns, isEditable?: boolean): GridColDef[] {
Copy link
Member

@Janpot Janpot May 6, 2024

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

Copy link
Contributor Author

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?

Copy link
Member

@Janpot Janpot May 6, 2024

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.

Copy link
Contributor Author

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.

@b4s36t4 b4s36t4 force-pushed the fix/default-editable-grid branch from 2797c76 to 825b970 Compare May 6, 2024 12:02
@b4s36t4
Copy link
Contributor Author

b4s36t4 commented May 6, 2024

@Janpot I have updated the changes you suggested, can you please verify.

return column;
}

column.editable = isRowUpdateModelAvailable;
Copy link
Member

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;

@Janpot
Copy link
Member

Janpot commented May 6, 2024

@Janpot I have updated the changes you suggested, can you please verify.

Can you look into why the tests fail?

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: out-of-date The pull request has merge conflicts and can't be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[studio] Cell shouldn't be editable by default
3 participants