Class GridHelper<T>
- All Implemented Interfaces:
Serializable
- See Also:
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CheckboxColumn<T>addCheckboxColumn(Grid<T> grid, CheckboxColumn.CheckboxColumnConfiguration<T> config) static <T> RegistrationaddColumnToggleListener(Grid<T> grid, ComponentEventListener<ColumnToggleEvent<T>> listener) Adds a listener that is notified when column visibility is modified through the sidebar menu.static voidaddToolbarFooter(Grid<?> grid, Component toolBar) static ComponentgetEmptyGridLabel(Grid<?> grid) Returns the component that is displayed when the Grid would show an empty data set.static StringgetFooter(Grid<?> grid, Grid.Column<?> column) Deprecated.static GridStylesHelpergetFooterStyles(Grid<?> grid, FooterRow row) static GridStylesHelpergetFooterStyles(Grid<?> grid, FooterRow.FooterCell cell) static StringgetHeader(Grid<?> grid, Grid.Column<?> column) Deprecated.static GridStylesHelpergetHeaderStyles(Grid<?> grid, HeaderRow row) static GridStylesHelpergetHeaderStyles(Grid<?> grid, HeaderRow.HeaderCell cell) static doublegetHeightByRows(Grid<?> grid) Gets the amount of rows in Grid's body that are shown, whilegetHeightMode(Grid)isHeightMode.ROW.static HeightModegetHeightMode(Grid<?> grid) Defines the mode in which the Grid's height is calculated.static <T> StringgetHidingToggleCaption(Grid.Column<T> column) Returns the caption of the hiding toggle for this column.static <T> Collection<GridResponsiveStep<T>>getResponsiveSteps(Grid<T> grid) Return the responsive steps of the givengrid.static <T> SerializablePredicate<T>getSelectionFilter(Grid<T> grid) Returns the predicate for determining which rows are selectable.static Grid.SelectionModegetSelectionMode(Grid<?> grid) Return the grid selection modestatic booleanisArrowSelectionEnabled(Grid<?> grid) Returns whether Grid rows can be selected using up/down arrow keys.static booleanisColumnToggleVisible(Grid<?> grid) Returns whether the menu to toggle the visibility of grid columns is visible.static booleanisEnhancedSelectionEnabled(Grid<?> grid) Returns whether the enhanced selection is enabled.static booleanisFooterVisible(Grid<?> grid) Returns the visibility of the footer section.static booleanisHeaderVisible(Grid<?> grid) Returns the visibility of the header section.static <T> booleanisHidable(Grid.Column<T> column) Returns whether this column can be hidden by the user.static booleanisMenuToggleColumn(Grid.Column<?> column) static booleanisSelectionColumnFrozen(Grid<?> grid) Deprecated.static booleanisSelectionColumnHidden(Grid<?> grid) Returns whether the multiselect selection column is hidden.static booleanisSelectOnClick(Grid<?> grid) static <T> GridResponsiveStep<T>responsiveStep(Grid<T> grid, int minWidth) Get or create a responsive steps for the givengridand minimum width.static voidsetArrowSelectionEnabled(Grid<?> grid, boolean value) Allows Grid rows to be selected using up/down arrow keys.voidsetClassNameGenerator(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 voidsetColumnToggleVisible(Grid<?> grid, boolean visible) Shows a menu to toggle the visibility of grid columns.static voidsetEmptyGridLabel(Grid<?> grid, Component component) Sets a component that is displayed when the Grid would show an empty data set.static final voidsetEnhancedSelectionEnabled(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.static voidsetFooterVisible(Grid<?> grid, boolean visible) Sets the visibility of the footer section.static voidsetHeaderVisible(Grid<?> grid, boolean visible) static voidsetHeightByRows(Grid<?> grid, double rows) Sets the number of rows that should be visible in Grid's body, whilegetHeightMode(Grid)isHeightMode.ROW.static voidsetHeightByRows(Grid<?> grid, int rows) Sets the number of rows that should be visible in Grid's body, whilegetHeightMode(Grid)isHeightMode.ROW.static voidsetHeightMode(Grid<?> grid, HeightMode heightMode) Defines the mode in which the Grid's height is calculated.protected voidsetHelperClassNameGenerator(Class<?> clazz, SerializableFunction<T, String> generator) static <T> Grid.Column<T>setHidable(Grid.Column<T> column, boolean hidable) Sets whether this column can be hidden by the user.static <T> voidsetHidingToggleCaption(Grid.Column<T> column, String caption) Sets the caption of the hiding toggle for this column.static voidsetSelectionColumnFrozen(Grid<?> grid, boolean value) Deprecated.static voidsetSelectionColumnHidden(Grid<?> grid, boolean value) Sets whether the multiselect selection column is hidden.static <T> voidsetSelectionFilter(Grid<T> grid, SerializablePredicate<T> predicate) Sets a predicate for determining which rows are selectable.static voidsetSelectOnClick(Grid<?> grid, boolean selectOnClick) static <T> GridRadioSelectionColumnshowRadioSelectionColumn(Grid<T> grid) static <T> voidtoggleSelectAllCheckbox(Grid<T> grid, boolean visible) Toggles select all checkbox visibility in the grid's default header row for the selection column.
-
Field Details
-
GRID_STYLES
- See Also:
-
DENSE_THEME
Compact row styling for Vaadin Grid- See Also:
-
-
Method Details
-
setHelperClassNameGenerator
protected void setHelperClassNameGenerator(Class<?> clazz, SerializableFunction<T, String> generator) -
getSelectionMode
Return the grid selection mode -
setClassNameGenerator
Sets the function that is used for generating CSS class names for all the cells in the rows in this grid. Returningnullfrom 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.- Parameters:
classNameGenerator- the class name generator to set, notnull- Throws:
NullPointerException- ifclassNameGeneratorisnull- See Also:
-
setSelectOnClick
-
isSelectOnClick
-
setArrowSelectionEnabled
Allows Grid rows to be selected using up/down arrow keys. -
isArrowSelectionEnabled
Returns whether Grid rows can be selected using up/down arrow keys. -
setSelectionColumnHidden
Sets whether the multiselect selection column is hidden. -
setSelectionColumnFrozen
Deprecated.Sets whether the multiselect selection column is frozen. -
isSelectionColumnHidden
Returns whether the multiselect selection column is hidden. -
isSelectionColumnFrozen
Deprecated.Returns whether the multiselect selection column is frozen. -
setSelectionFilter
Sets a predicate for determining which rows are selectable.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
-
getSelectionFilter
Returns the predicate for determining which rows are selectable. -
setColumnToggleVisible
Shows a menu to toggle the visibility of grid columns. -
isColumnToggleVisible
Returns whether the menu to toggle the visibility of grid columns is visible. -
isHidable
Returns whether this column can be hidden by the user. Default isfalse.- Returns:
trueif the user can hide the column,falseif not.
-
setHidable
Sets whether this column can be hidden by the user. Hidable columns can be hidden and shown via the sidebar menu.- Parameters:
column- the column to be configuredhidable-trueif the column may be hidden by the user via UI interaction- Returns:
- the column.
-
addColumnToggleListener
public static <T> Registration addColumnToggleListener(Grid<T> grid, ComponentEventListener<ColumnToggleEvent<T>> listener) Adds a listener that is notified when column visibility is modified through the sidebar menu. -
setHidingToggleCaption
Sets the caption of the hiding toggle for this column. Shown in the toggle for this column in the grid's sidebar when the column is hidable.If the value is
null, the column cannot be hidden via the sidebar menu.- Parameters:
column- the column for which the hiding toggle caption is setcaption- the text to show in the column hiding toggle
-
getHidingToggleCaption
Returns the caption of the hiding toggle for this column.- Returns:
- the text shown in the column hiding toggle
-
isMenuToggleColumn
-
setEmptyGridLabel
Sets a component that is displayed when the Grid would show an empty data set. -
getEmptyGridLabel
Returns the component that is displayed when the Grid would show an empty data set. -
getHeader
Deprecated. -
setEnhancedSelectionEnabled
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.- Parameters:
grid-enabled-
-
isEnhancedSelectionEnabled
Returns whether the enhanced selection is enabled. -
setHeaderVisible
-
isHeaderVisible
Returns the visibility of the header section.- Returns:
- true if visible, false otherwise.
-
getHeaderStyles
-
getHeaderStyles
-
setHeightByRows
Sets the number of rows that should be visible in Grid's body, whilegetHeightMode(Grid)isHeightMode.ROW.The algorithm assumes that all data rows have the same height and considers headers, footers, and the horizontal scrollbar when the method is called. However, if data rows, headers, or footers are inserted or removed after the initial calculation, the grid may not automatically adjust the size of the grid to accommodate the changed number of rows.
- Parameters:
rows- The height in terms of number of rows displayed in Grid's body. If Grid doesn't contain enough rows, white space is displayed instead.- Throws:
IllegalArgumentException- ifrowsis zero or lessIllegalArgumentException- ifrowsisinfiniteIllegalArgumentException- ifrowsisNaN
-
setHeightByRows
Sets the number of rows that should be visible in Grid's body, whilegetHeightMode(Grid)isHeightMode.ROW.If Grid is currently not in
HeightMode.ROW, the given value is remembered, and applied once the mode is applied. @SeesetHeightByRows(Grid, double) -
getHeightByRows
Gets the amount of rows in Grid's body that are shown, whilegetHeightMode(Grid)isHeightMode.ROW.- Returns:
- the amount of rows that are being shown in Grid's body
- See Also:
-
setHeightMode
Defines the mode in which the Grid's height is calculated.If
HeightMode.CSSis given, Grid will respect the values given via asetHeight-method, and behave as a traditional Component.If
HeightMode.ROWis given, Grid will make sure that the body will display as many rows asgetHeightByRows(Grid)defines.- Parameters:
heightMode- the mode in to which Grid should be set
-
getHeightMode
Defines the mode in which the Grid's height is calculated.If
HeightMode.CSSis given, Grid will respect the CSS height as a traditional Component.If
HeightMode.ROWis given, Grid will make sure that the body will display as many rows asgetHeightByRows(Grid)defines.- Returns:
- the mode in which the Grid is set
-
responsiveStep
Get or create a responsive steps for the givengridand minimum width. -
getResponsiveSteps
Return the responsive steps of the givengrid. -
addCheckboxColumn
public static <T> CheckboxColumn<T> addCheckboxColumn(Grid<T> grid, CheckboxColumn.CheckboxColumnConfiguration<T> config) -
toggleSelectAllCheckbox
Toggles select all checkbox visibility in the grid's default header row for the selection column.Only works when Grid uses
Grid.SelectionMode.MULTIand the data provider supplies a count callback.Note: enabling the select all checkbox when grid uses a lazy data source could lead to memory and performance issues.
- Parameters:
visible- true to show the select all checkbox, false to hide it.- See Also:
-
LazySelectAllGridHelper
-
showRadioSelectionColumn
-