Directory

← Back

Enhanced Grid

This component is an extended version of Grid with integrated complex filtering and other features

Author

Rating

Popularity

300+

This component is an extended version of Grid to add support to the following features:

Features

set a predicate to indicate which rows/items can be selected

EnhancedGrid#setSelectionPredicate(SerializablePredicate)

set a predicate to indicate which rows/items can be edited

EnhancedGrid#setEditablePredicate(SerializablePredicate)

check if a item is editable

EnhancedGrid#isEditable(T)

edit an item and cancel the edit

EnhancedGrid#editItem(T)
EnhancedGrid#cancelEdit()

set a flag to indicate if a cancel edit confirmation dialog should be display if user navigates away from current editing row

EnhancedGrid#setShowCancelEditDialog(boolean)

Each column can define a filter field/dialog through

EnhancedColumn#setHeader(String, HasValueAndElement)
EnhancedColumn#setHeader(Component, HasValueAndElement)

Major pieces of development of this add-on has been sponsored by multiple customers of Vaadin. Read more about Expert on Demand at: Support and Pricing

Sample code

// create grid
EnhancedGrid<Person> grid = new EnhancedGrid<>();

// set selection predicate to indicate which items can be selected
grid.setSelectionPredicate(p -> p.getAge() > 18);

// set items
grid.setItems(personService.fetchAll());

// add columns
// first name column with filtering button on header
EnhancedColumn<Person> firstNameColumn = grid.addColumn(Person::getFirstName).setHeader("First Name", new TextFilterField());
// last name column with filtering button and pre-selected filter by last name = "Allen"
grid.addColumn(Person::getLastName).setHeader("Last Name", new TextFilterField(new TextFieldFilterDto("Allen")));
// age column with renderer
NumberRenderer<Person> ageRenderer = new NumberRenderer<Person>(Person::getAge, "Age: %d");
EnhancedColumn<Person> ageColumn = grid.addColumn(ageRenderer, PersonSort.AGE).setHeader("Age", new TextFilterField());
ageColumn.setValueProvider(p -> String.valueOf(p.getAge()));

// add pre-selected descendent order for first name column
List<GridSortOrder<Person>> sortByFirstName = new GridSortOrderBuilder<Person>()
	  .thenDesc(firstNameColumn).build();
grid.sort(sortByFirstName);

// set selection mode
grid.setSelectionMode(Grid.SelectionMode.SINGLE);

// can pre-select items
grid.select(personList.get(0));
	   
// set editable predicate to indicate which items can be edited
grid.setEditablePredicate(p -> p.getAge() > 18);        

// add binder and editor for grid
Binder<Person> binder = new Binder<>(Person.class);
Editor<Person> editor = grid.getEditor();
editor.setBinder(binder);
editor.setBuffered(true);
 
// define editor components for columns
TextField firstNameField = new TextField();
binder.bind(firstNameField, Person::getFirstName, Person::setFirstName);
firstNameColumn.setEditorComponent(firstNameField);
	   
// call edit
grid.addItemDoubleClickListener(event -> {
	grid.editItem(event.getItem());
	firstNameField.focus();
});
        

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Fixes issue with header components not being restored when using @PreserveOnRefresh

Released
2024-01-12
Maturity
EXPERIMENTAL
License
Apache License 2.0

Compatibility

Framework
Vaadin 24
Vaadin 14 in 0.4.0
Vaadin 22 in 2.0.0
Vaadin 21 in 2.0.0
Vaadin 23 in 3.0.0
Browser
N/A

Enhanced Grid - Vaadin Add-on Directory

This component is an extended version of Grid with integrated complex filtering and other features Enhanced Grid - Vaadin Add-on Directory
This component is an extended version of Grid to add support to the following features: ## Features ### set a predicate to indicate which rows/items can be selected EnhancedGrid#setSelectionPredicate(SerializablePredicate) ### set a predicate to indicate which rows/items can be edited EnhancedGrid#setEditablePredicate(SerializablePredicate) ### check if a item is editable EnhancedGrid#isEditable(T) ### edit an item and cancel the edit EnhancedGrid#editItem(T) EnhancedGrid#cancelEdit() ### set a flag to indicate if a cancel edit confirmation dialog should be display if user navigates away from current editing row EnhancedGrid#setShowCancelEditDialog(boolean) ### Each column can define a filter field/dialog through EnhancedColumn#setHeader(String, HasValueAndElement) EnhancedColumn#setHeader(Component, HasValueAndElement) ### Sponsored development Major pieces of development of this add-on has been sponsored by multiple customers of Vaadin. Read more about Expert on Demand at: [Support](https://vaadin.com/support) and [Pricing](https://vaadin.com/pricing)
Online