@JsModule(value="./fcGridHelper/connector.js") @CssImport(value="./fcGridHelper/vaadin-menu-bar.css",themeFor="vaadin-menu-bar") @CssImport(value="./fcGridHelper/vaadin-grid.css",themeFor="vaadin-grid") @CssImport(value="./fcGridHelper/vaadin-context-menu-item.css",themeFor="vaadin-context-menu-item") @CssImport(value="./fcGridHelper/vaadin-context-menu-list-box.css",themeFor="vaadin-context-menu-list-box") public final class GridHelper<T> extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
DENSE_THEME
Compact row styling for Vaadin Grid
|
static String |
GRID_STYLES |
Modifier and Type | Method and Description |
---|---|
static <T> com.vaadin.flow.shared.Registration |
addColumnToggleListener(com.vaadin.flow.component.grid.Grid<T> grid,
com.vaadin.flow.component.ComponentEventListener<ColumnToggleEvent<T>> listener)
Adds a listener that is notified when column visibility is modified through the sidebar menu.
|
static void |
addToolbarFooter(com.vaadin.flow.component.grid.Grid<?> grid,
com.vaadin.flow.component.Component toolBar) |
static com.vaadin.flow.component.Component |
getEmptyGridLabel(com.vaadin.flow.component.grid.Grid<?> grid)
Returns the component that is displayed when the Grid would show an empty data set.
|
static String |
getFooter(com.vaadin.flow.component.grid.Grid<?> grid,
com.vaadin.flow.component.grid.Grid.Column<?> column) |
static String |
getHeader(com.vaadin.flow.component.grid.Grid<?> grid,
com.vaadin.flow.component.grid.Grid.Column<?> column) |
static <T> String |
getHidingToggleCaption(com.vaadin.flow.component.grid.Grid.Column<T> column)
Returns the caption of the hiding toggle for this column.
|
static <T> com.vaadin.flow.function.SerializablePredicate<T> |
getSelectionFilter(com.vaadin.flow.component.grid.Grid<T> grid)
Returns the predicate for determining which rows are selectable.
|
static com.vaadin.flow.component.grid.Grid.SelectionMode |
getSelectionMode(com.vaadin.flow.component.grid.Grid<?> grid)
Return the grid selection mode
|
static boolean |
isArrowSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid)
Returns whether Grid rows can be selected using up/down arrow keys.
|
static boolean |
isColumnToggleVisible(com.vaadin.flow.component.grid.Grid<?> grid)
Returns whether the menu to toggle the visibility of grid columns is visible.
|
static boolean |
isEnhancedSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid)
Returns whether the enhanced selection is enabled.
|
static <T> boolean |
isHidable(com.vaadin.flow.component.grid.Grid.Column<T> column)
Returns whether this column can be hidden by the user.
|
static boolean |
isMenuToggleColumn(com.vaadin.flow.component.grid.Grid.Column<?> column) |
static boolean |
isSelectionColumnFrozen(com.vaadin.flow.component.grid.Grid<?> grid)
Returns whether the multiselect selection column is frozen.
|
static boolean |
isSelectionColumnHidden(com.vaadin.flow.component.grid.Grid<?> grid)
Returns whether the multiselect selection column is hidden.
|
static boolean |
isSelectOnClick(com.vaadin.flow.component.grid.Grid<?> grid) |
static void |
setArrowSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid,
boolean value)
Allows Grid rows to be selected using up/down arrow keys.
|
void |
setClassNameGenerator(com.vaadin.flow.function.SerializableFunction<T,String> classNameGenerator)
Sets the function that is used for generating CSS class names for all the cells in the rows in
this grid.
|
static void |
setColumnToggleVisible(com.vaadin.flow.component.grid.Grid<?> grid,
boolean visible)
Shows a menu to toggle the visibility of grid columns.
|
static void |
setEmptyGridLabel(com.vaadin.flow.component.grid.Grid<?> grid,
com.vaadin.flow.component.Component component)
Sets a component that is displayed when the Grid would show an empty data set.
|
static void |
setEnhancedSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid,
boolean enabled)
When enabled, enhances grid row selection support adding support for these combinations: click, arrow
up/down, shift+click, shift+arrow up/down, ctrl+click and ctrl+space.
|
protected void |
setHelperClassNameGenerator(Class<?> clazz,
com.vaadin.flow.function.SerializableFunction<T,String> generator) |
static <T> com.vaadin.flow.component.grid.Grid.Column<T> |
setHidable(com.vaadin.flow.component.grid.Grid.Column<T> column,
boolean hidable)
Sets whether this column can be hidden by the user.
|
static <T> void |
setHidingToggleCaption(com.vaadin.flow.component.grid.Grid.Column<T> column,
String caption)
Sets the caption of the hiding toggle for this column.
|
static void |
setSelectionColumnFrozen(com.vaadin.flow.component.grid.Grid<?> grid,
boolean value)
Sets whether the multiselect selection column is frozen.
|
static void |
setSelectionColumnHidden(com.vaadin.flow.component.grid.Grid<?> grid,
boolean value)
Sets whether the multiselect selection column is hidden.
|
static <T> void |
setSelectionFilter(com.vaadin.flow.component.grid.Grid<T> grid,
com.vaadin.flow.function.SerializablePredicate<T> predicate)
Sets a predicate for determining which rows are selectable.
|
static void |
setSelectOnClick(com.vaadin.flow.component.grid.Grid<?> grid,
boolean selectOnClick) |
public static final String GRID_STYLES
public static final String DENSE_THEME
protected void setHelperClassNameGenerator(Class<?> clazz, com.vaadin.flow.function.SerializableFunction<T,String> generator)
public static com.vaadin.flow.component.grid.Grid.SelectionMode getSelectionMode(com.vaadin.flow.component.grid.Grid<?> grid)
public void setClassNameGenerator(com.vaadin.flow.function.SerializableFunction<T,String> classNameGenerator)
null
from the generator results in no custom class name being set.
Multiple class names can be returned from the generator as space-separated.
If Grid.Column.setClassNameGenerator(SerializableFunction)
is used together with this
method, resulting class names from both methods will be effective. Class names generated by
grid are applied to the cells before the class names generated by column. This means that if
the classes contain conflicting style properties, column's classes will win.
classNameGenerator
- the class name generator to set, not null
NullPointerException
- if classNameGenerator
is null
Grid.Column.setClassNameGenerator(SerializableFunction)
public static void setSelectOnClick(com.vaadin.flow.component.grid.Grid<?> grid, boolean selectOnClick)
public static boolean isSelectOnClick(com.vaadin.flow.component.grid.Grid<?> grid)
public static void setArrowSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid, boolean value)
public static boolean isArrowSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid)
public static void setSelectionColumnHidden(com.vaadin.flow.component.grid.Grid<?> grid, boolean value)
public static void setSelectionColumnFrozen(com.vaadin.flow.component.grid.Grid<?> grid, boolean value)
public static boolean isSelectionColumnHidden(com.vaadin.flow.component.grid.Grid<?> grid)
public static boolean isSelectionColumnFrozen(com.vaadin.flow.component.grid.Grid<?> grid)
public static <T> void setSelectionFilter(com.vaadin.flow.component.grid.Grid<T> grid, com.vaadin.flow.function.SerializablePredicate<T> predicate)
After a call to Grid.setSelectionMode(SelectionMode)
the selection filter is lost and
it has to be configured again:
GridHelper.setSelectionFilter(grid, GridHelper.getSelectionFilter(grid)); // static call grid.setSelectionFilter(grid.getSelectionFilter()); // with lombok extension
public static <T> com.vaadin.flow.function.SerializablePredicate<T> getSelectionFilter(com.vaadin.flow.component.grid.Grid<T> grid)
public static void setColumnToggleVisible(com.vaadin.flow.component.grid.Grid<?> grid, boolean visible)
public static boolean isColumnToggleVisible(com.vaadin.flow.component.grid.Grid<?> grid)
public static <T> boolean isHidable(com.vaadin.flow.component.grid.Grid.Column<T> column)
false
.true
if the user can hide the column, false
if not.public static <T> com.vaadin.flow.component.grid.Grid.Column<T> setHidable(com.vaadin.flow.component.grid.Grid.Column<T> column, boolean hidable)
column
- the column to be configuredhidable
- true
if the column may be hidden by the user via UI interactionpublic static <T> com.vaadin.flow.shared.Registration addColumnToggleListener(com.vaadin.flow.component.grid.Grid<T> grid, com.vaadin.flow.component.ComponentEventListener<ColumnToggleEvent<T>> listener)
public static <T> void setHidingToggleCaption(com.vaadin.flow.component.grid.Grid.Column<T> column, String caption)
If the value is null
, the column cannot be hidden via the sidebar menu.
hidingToggleCaption
- the text to show in the column hiding togglepublic static <T> String getHidingToggleCaption(com.vaadin.flow.component.grid.Grid.Column<T> column)
public static boolean isMenuToggleColumn(com.vaadin.flow.component.grid.Grid.Column<?> column)
public static void setEmptyGridLabel(com.vaadin.flow.component.grid.Grid<?> grid, com.vaadin.flow.component.Component component)
public static com.vaadin.flow.component.Component getEmptyGridLabel(com.vaadin.flow.component.grid.Grid<?> grid)
public static void addToolbarFooter(com.vaadin.flow.component.grid.Grid<?> grid, com.vaadin.flow.component.Component toolBar)
public static String getHeader(com.vaadin.flow.component.grid.Grid<?> grid, com.vaadin.flow.component.grid.Grid.Column<?> column)
public static String getFooter(com.vaadin.flow.component.grid.Grid<?> grid, com.vaadin.flow.component.grid.Grid.Column<?> column)
public static final void setEnhancedSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid, boolean enabled)
grid
- enabled
- public static boolean isEnhancedSelectionEnabled(com.vaadin.flow.component.grid.Grid<?> grid)
Copyright © 2022–2023 Flowing Code. All rights reserved.