AutoCrud edit-only?

I was trying to figure out if there was a way to make the AutoCrud component edit-only? E.g. I would like to make sure that the New and Delete buttons don’t show up essentially. Users should be able to modify the rows that already exist in the table, but shouldn’t be able to add more or delete existing (there is an active column…).

I couldn’t find anything in the docs, or a cursory look through the AutoCrud component source. Also couldn’t find any discussion on the forum, so I figured I might as well ask.

Edit: I found out how to disable the Delete button in the formProps, but can’t find anything for the New button.

There is no built-in feature for disabling the new button, you could request it here: GitHub - vaadin/hilla: Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.

As a workaround you could:

  • Hide the button using CSS, for example by hiding the Auto Crud toolbar which you can target with the auto-crud-toolbar CSS class.
  • Customize your CrudService in the backend to disallow creating new items

Note that making the delete button invisible would still allow deleting items in the Crud service, so you might want to customize that as well.

Thanks for the workaround. Will give that a shot.

Also, opened a feature request for that capability: Disable New Button in AutoCrud Component · Issue #3227 · vaadin/hilla · GitHub

Thanks!

I noticed that the form header also says “New item” by default. For that you could override formProps.headerRenderer to make it always show “Edit item”.