CRUD
- Columns
- Editor
- Grid Replacement
- Toolbar
- Sorting and Filtering
- Item Initialization
- Localization
- Related Components
Note
|
Commercial feature
A commercial Vaadin subscription is required to use CRUD in your project. |
CRUD is a component for managing a dataset. It allows for easy displaying, editing, creating, and deleting of items.
new tab
Source code
crud-basic.ts
CrudBasic.java
PersonDataProvider.java
PersonDataProvider.java
Columns
CRUD automatically generates columns for each field in the provided dataset. You can add columns with it and configure or remove existing ones.
new tab
Source code
crud-columns.ts
CrudColumns.java
PersonDataProvider.java
PersonDataProvider.java
Editor
Data is edited using CRUD’s editor UI.
Opening the Editor
By default, the editor is opened by clicking the edit Button in the last column. However, this button column can be removed if you want to provide an alternative way to engage the editor. For example, you can have it open using a double click like so:
new tab
Source code
crud-open-editor.ts
CrudOpenEditor.java
PersonDataProvider.java
PersonDataProvider.java
Editor Position
The editor can be positioned in an overlay, on the side, or at the bottom.
Overlay (Default)
The overlay position renders the editor in a modal overlay. Overlays aren’t constrained to the CRUD’s size. This makes them ideal for complex forms. However, they block the user from viewing and interacting with the Grid beneath.
Aside
The aside
position displays the editor as an overlay next to the grid.
Use this position when there is sufficient horizontal space to accommodate both the grid and the editor, and when it’s beneficial for the user to be able to view and interact with the grid while the editor is open.
Aside positioning is also a good fit for single-column forms.
new tab
Source code
crud-editor-aside.ts
CrudEditorAside.java
PersonDataProvider.java
PersonDataProvider.java
Note
|
Grid Width
The opening and closing of an aside editor affects the grid’s width.
Fixed-width columns are recommended to prevent them from resizing each time.
|
Bottom
The bottom position can be useful when the user needs to see as many columns in the grid as possible while editing, when horizontal space is limited, or when a wider editor form is desired.
new tab
Source code
crud-editor-bottom.ts
CrudEditorBottom.java
PersonDataProvider.java
PersonDataProvider.java
When using a bottom-positioned editor, make sure there is enough vertical space to fit both the grid and the editor comfortably. A bottom-positioned editor is an inappropriate option for longer forms.
Note
|
Small viewports
On small viewports, like mobile phones, the editor always opens up as a full-screen overlay, regardless of this configuration.
|
Editor Content
The editor’s content is fully configurable, except for the header and footer.
new tab
Source code
crud-editor-content.ts
CrudEditorContent.java
PersonDataProvider.java
PersonDataProvider.java
Editor Actions
-
"Delete" shows a confirmation dialog asking the user to verify whether they wish to delete the item.
-
"Cancel" closes the editor unless there are unsaved changes. If there are, a confirmation dialog is shown and the user can either discard the changes or go back to editing.
-
"Save" saves the changes and closes the editor. This is disabled until a change is made.
Grid Replacement
CRUD’s default Grid is replaceable. This is useful when you wish to customize the Grid. An example might be if you want to place the edit Button in the first column, or to apply tooltips. See Grid documentation for details on configuring grids.
new tab
Source code
crud-grid-replacement.ts
CrudGridReplacement.java
PersonDataProvider.java
PersonDataProvider.java
Note
|
Edit Column
You need to add explicitly an edit column to the replacement Grid to edit items.
Additionally, Grid doesn’t have sorting and filtering enabled by default.
|
Toolbar
Creating new items is done via the “New item” Button in CRUD’s toolbar. Both the toolbar and its Button are customizable. For example, you can use the toolbar to display statistics such as the size of the dataset or the number of search results.
new tab
Source code
crud-toolbar.ts
CrudToolbar.java
PersonDataProvider.java
PersonDataProvider.java
Hiding the Toolbar
The toolbar can be hidden if it isn’t needed.
new tab
Source code
crud-hidden-toolbar.ts
CrudHiddenToolbar.java
Sorting and Filtering
By default, CRUD allows sorting and filtering of any column. For more information about sorting and filtering, see the Grid documentation.
Disabling Sorting and Filtering
Sorting and filtering can be disabled.
new tab
Source code
crud-sorting-filtering.ts
CrudSortingFiltering.java
PersonDataProvider.java
PersonDataProvider.java
Item Initialization
Newly created items can be initialized with data.
new tab
Source code
crud-item-initialization.ts
CrudItemInitialization.java
Localization
CRUD supports full localization through customizable labels for its buttons and the title of the editor.
new tab