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

Feat: creating row with external button #903

Merged

Conversation

dangkhoa99
Copy link
Contributor

Hello @KevinVandy,

According to your code, when using creatingDisplayMode = 'row', it will automatically create save and cancel buttons in the action column.

But in my case, I want to use save, cancel buttons in the table header to be able to control creatingRow. Can you review and merge the code?

Example:
image

Copy link

vercel bot commented Jan 2, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
material-react-table ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2024 4:14pm
material-react-table-storybook ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2024 4:14pm

@KevinVandy
Copy link
Owner

@dangkhoa99 I think my changes to this PR make more sense. Take a look

@dangkhoa99
Copy link
Contributor Author

dangkhoa99 commented Jan 2, 2024

@KevinVandy In my case, when enableRowAction = false, I want when creatingDisplayMode="row" the save or cancel button does not show the action column and the buttons are shown on the table header.

@KevinVandy
Copy link
Owner

KevinVandy commented Jan 2, 2024

The problem is that onCreatingRowCancel is not a required option, so we cannot rely on it for conditional rendering

@KevinVandy
Copy link
Owner

You can just use columnVisibility state to completely hide the actions column if needed

@dangkhoa99
Copy link
Contributor Author

I set enableRowAction = false in useMaterialReactTable but this column still show when i setCreatingRow(true)

@dangkhoa99
Copy link
Contributor Author

I want to implement both editingMode and creatingMode = 'row' similar to MUI as referenced link below:
https://mui.com/x/react-data-grid/editing/#controlled-model

Copy link
Owner

@KevinVandy KevinVandy left a comment

Choose a reason for hiding this comment

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

Hide row save button unless onCreatingRowSave has been defined

@KevinVandy KevinVandy merged commit 82120c0 into KevinVandy:v2 Jan 4, 2024
3 of 4 checks passed
@dangkhoa99 dangkhoa99 mentioned this pull request Jan 4, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants