Skip to content
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

[docs] Row and cell editing new examples for server-side persistence #3124

Merged

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Nov 8, 2021

Closes #3101

@flaviendelangle flaviendelangle added docs Improvements or additions to the documentation components: DataGridPro labels Nov 8, 2021
@flaviendelangle flaviendelangle self-assigned this Nov 8, 2021
@flaviendelangle flaviendelangle marked this pull request as ready for review November 15, 2021 10:58
docs/src/pages/components/data-grid/editing/editing.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/editing/editing.md Outdated Show resolved Hide resolved
docs/src/pages/components/data-grid/editing/editing.md Outdated Show resolved Hide resolved
const handleCellEditCommit = React.useCallback(
async (params: GridCellEditCommitParams) => {
// Get the row old value before committing
const oldRow = apiRef.current.getRow(params.id)!;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get the row from the rows prop and make this demo Community-compatible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

} catch (error) {
setSnackbar({ children: 'Error while saving user', severity: 'error' });
// Restore the row in case of error
apiRef.current.updateRows([oldRow]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rows prop can be updated instead.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

docs/src/pages/components/data-grid/editing/editing.md Outdated Show resolved Hide resolved
@flaviendelangle
Copy link
Member Author

OK I was way to short on that one sorry, I'll fix those

docs/src/pages/components/data-grid/editing/editing.md Outdated Show resolved Hide resolved
@@ -17,6 +17,14 @@ Set the `editable` property in the `GridColDef` object to `true` to allow editin

{{"demo": "pages/components/data-grid/editing/BasicEditingGrid.js", "bg": "inline", "defaultCodeOpen": false}}

### Server-side persistence
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not be the first section. The user has just opened the editing page to learn how it works. I think it could be below "Server-side validation".

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Co-authored-by: Matheus Wichman <matheushw@outlook.com>
@flaviendelangle flaviendelangle merged commit 6088bfb into mui:master Nov 26, 2021
@flaviendelangle flaviendelangle deleted the editing-server-persistence branch November 26, 2021 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[DataGrid] Add documentation on how to persist edited cells/rows
2 participants