Class Grid<T>

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.grid.Grid<T>
Type Parameters:
T - the grid bean type
All Implemented Interfaces:
AttachNotifier, BlurNotifier<Grid<T>>, DetachNotifier, Focusable<Grid<T>>, FocusNotifier<Grid<T>>, HasElement, HasEnabled, HasSize, HasStyle, HasTheme, SortEvent.SortNotifier<Grid<T>,GridSortOrder<T>>, HasDataGenerators<T>, HasDataView<T,Void,GridDataView<T>>, HasLazyDataView<T,Void,GridLazyDataView<T>>, HasListDataView<T,GridListDataView<T>>, Serializable
Direct Known Subclasses:
CrudGrid, GridPro, TreeGrid

@Tag("vaadin-grid") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.3.11") @NpmPackage(value="@vaadin/grid",version="24.3.11") @NpmPackage(value="@vaadin/tooltip",version="24.3.11") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/grid/src/vaadin-grid.js") @JsModule("@vaadin/grid/src/vaadin-grid-column.js") @JsModule("@vaadin/grid/src/vaadin-grid-sorter.js") @JsModule("@vaadin/checkbox/src/vaadin-checkbox.js") @JsModule("./flow-component-renderer.js") @JsModule("./gridConnector.ts") @JsModule("@vaadin/tooltip/src/vaadin-tooltip.js") public class Grid<T> extends Component implements HasStyle, HasSize, Focusable<Grid<T>>, SortEvent.SortNotifier<Grid<T>,GridSortOrder<T>>, HasTheme, HasDataGenerators<T>, HasListDataView<T,GridListDataView<T>>, HasDataView<T,Void,GridDataView<T>>, HasLazyDataView<T,Void,GridLazyDataView<T>>
Grid is a component for showing tabular data. A basic Grid uses plain text to display information in rows and columns. However, rich content can be used to provide additional information in a more legible fashion using component renderers or Lit renderers. The Grid supports the following features.

Dynamic Height:
Grid has a default height of 400 pixels. It becomes scrollable when its items overflow the allocated space. In addition to setting any fixed or relative value, the height of a grid can be set by the number of items in the dataset, meaning that the grid will grow and shrink based on the row count.

Selection:
Grid selection is not enabled by default. Grid supports single and multi-select. The former allows the user to select exactly one item while the latter enables multiple items to be selected. In single selection mode, the user can select and deselect rows by clicking anywhere on the row. In multi-select mode, the user can use a checkbox column to select and deselect rows.

Columns:
Column alignment, freezing (fixed position), grouping, headers & footers, visibility, and width can be configured. Users can be allowed to resize and reorder columns.

Sorting:
Any column can be made sortable. Enable sorting to allow the user to sort items alphabetically, numerically, by date, etc. You can also sort columns that contain rich and/or custom content by defining which property to sort by. For example, you can have a column containing a person’s profile picture, name and email sorted by the person’s last name. Sorting helps users find and analyze the data, so it’s generally recommended to enable it for all applicable columns, except in cases where the order of items is an essential part of the data itself (such as prioritized lists).

Filtering:
Filtering allows the user to quickly find a specific item or subset of items. You can add filters to Grid columns or use external filter fields.

Item Details:
Item Details are expandable content areas that can be displayed below the regular content of a row, used to display more information about an item. By default, an item’s details are toggled by clicking on the item’s row. The default toggle behavior can be replaced by programmatically toggling the details visibility, for example, from a button click.

Context Menu:
You can use Context Menu to provide shortcuts to the user. It appears on right (default) or left click. In a mobile browser, a long press opens the menu.

Drag and Drop:
Grid supports drag and drop, for example to reorder rows and to drag rows between grids.

Inline Editing:
Grid can be configured to allow inline editing. Editing can be either buffered and non-buffered. Buffered means changes must be explicitly committed, while non-buffered automatically commit changes on blur (when a field loses focus).

Styling Rows and Columns:
You can style individual cells based on the data, for example, to highlight changes or important information.

Cell Focus:
Cells can be focused by clicking on a cell or with the keyboard.

Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • Grid

      public Grid()
      Creates a new instance, with page size of 50.
    • Grid

      public Grid(DataProvider<T,Void> dataProvider)
      Creates a new grid using the given generic DataProvider.
      Parameters:
      dataProvider - the data provider, not null
    • Grid

      public Grid(BackEndDataProvider<T,Void> dataProvider)
      Creates a new grid using the given BackEndDataProvider.
      Parameters:
      dataProvider - the data provider, not null
    • Grid

      public Grid(InMemoryDataProvider<T> inMemoryDataProvider)
      Creates a new grid using the given InMemoryDataProvider.
      Parameters:
      inMemoryDataProvider - the data provider, not null
    • Grid

      public Grid(ListDataProvider<T> dataProvider)
      Creates a new grid using the given ListDataProvider.
      Parameters:
      dataProvider - the data provider, not null
    • Grid

      public Grid(Collection<T> items)
      Creates a new grid using the given collection of items using a ListDataProvider.
      Parameters:
      items - the collection of items, not null
    • Grid

      public Grid(int pageSize)
      Creates a new instance, with the specified page size.

      The page size influences the Query.getLimit() sent by the client, but it's up to the webcomponent to determine the actual query limit, based on the height of the component and scroll position. Usually the limit is 3 times the page size (e.g. 150 items with a page size of 50).

      Parameters:
      pageSize - the page size. Must be greater than zero.
    • Grid

      public Grid(Class<T> beanType, boolean autoCreateColumns)
      Creates a new grid with an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as the column keys and the property captions will be used as the column headers. The generated columns will be sortable by default, if the property is Comparable.

      When autoCreateColumns is true, only the direct properties of the bean are included and they will be in alphabetical order. Use setColumns(String...) to define which properties to include and in which order. You can also add a column for an individual property with addColumn(String). Both of these methods support also sub-properties with dot-notation, eg. "property.nestedProperty".

      Parameters:
      beanType - the bean type to use, not null
      autoCreateColumns - when true, columns are created automatically for the properties of the beanType
    • Grid

      public Grid(Class<T> beanType)
      Creates a new grid with an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as the column keys and the property captions will be used as the column headers. The generated columns will be sortable by default, if the property is Comparable.

      By default, only the direct properties of the bean are included and they will be in alphabetical order. Use setColumns(String...) to define which properties to include and in which order. You can also add a column for an individual property with addColumn(String). Both of these methods support also sub-properties with dot-notation, eg. "property.nestedProperty".

      Parameters:
      beanType - the bean type to use, not null
    • Grid

      protected Grid(Class<T> beanType, SerializableBiFunction<GridArrayUpdater.UpdateQueueData,Integer,Grid.UpdateQueue> updateQueueBuilder, B dataCommunicatorBuilder)
      Creates a new grid with an initial set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as the column keys and the property captions will be used as the column headers.

      You can add columns for nested properties of the bean with addColumn(String).

      Type Parameters:
      B - the data communicator builder type
      U - the GridArrayUpdater type
      Parameters:
      beanType - the bean type to use, not null
      updateQueueBuilder - the builder for new Grid.UpdateQueue instance
      dataCommunicatorBuilder - Builder for DataCommunicator implementation this Grid uses to handle all data communication.
    • Grid

      protected Grid(int pageSize, SerializableBiFunction<GridArrayUpdater.UpdateQueueData,Integer,Grid.UpdateQueue> updateQueueBuilder, B dataCommunicatorBuilder)
      Creates a new instance, with the specified page size and data communicator.

      The page size influences the Query.getLimit() sent by the client, but it's up to the webcomponent to determine the actual query limit, based on the height of the component and scroll position. Usually the limit is 3 times the page size (e.g. 150 items with a page size of 50).

      Type Parameters:
      B - the data communicator builder type
      U - the GridArrayUpdater type
      Parameters:
      pageSize - the page size. Must be greater than zero.
      updateQueueBuilder - the builder for new Grid.UpdateQueue instance
      dataCommunicatorBuilder - Builder for DataCommunicator implementation this Grid uses to handle all data communication.
  • Method Details

    • setDefaultMultiSortPriority

      public static void setDefaultMultiSortPriority(Grid.MultiSortPriority priority)
      Sets the default multi-sort priority to use for all Grid instances.

      This method should be called before creating any Grid instances. Changing this setting does not affect the default for existing Grids. Use setMultiSort(boolean, MultiSortPriority) to provide a custom multi-sort priority overriding the default priority for a single Grid.

      Parameters:
      priority - the multi-sort priority to be used by all grid instances
    • initConnector

      protected void initConnector()
    • createDefaultArrayUpdater

      protected GridArrayUpdater createDefaultArrayUpdater(SerializableBiFunction<GridArrayUpdater.UpdateQueueData,Integer,Grid.UpdateQueue> updateQueueFactory)
    • addColumn

      public Grid.Column<T> addColumn(ValueProvider<T,?> valueProvider)
      Adds a new text column to this Grid with a value provider and default column factory. The value is converted to String when sent to the client by using String.valueOf(Object).

      NOTE: For displaying components, see addComponentColumn(ValueProvider). For using build-in renderers, see addColumn(Renderer).

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      NOTE: This method is a shorthand for addColumn(ValueProvider, BiFunction)

      Parameters:
      valueProvider - the value provider
      Returns:
      the created column
      See Also:
    • addColumn

      protected <C extends Grid.Column<T>> C addColumn(ValueProvider<T,?> valueProvider, BiFunction<Renderer<T>,String,C> columnFactory)
      Adds a new text column to this Grid with a value provider and column factory provided. The value is converted to String when sent to the client by using String.valueOf(Object).

      NOTE: For displaying components, see addComponentColumn(ValueProvider). For using build-in renderers, see addColumn(Renderer).

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Parameters:
      valueProvider - the value provider
      columnFactory - the method that creates a new column instance for this Grid instance.
      Returns:
      the created column
      See Also:
    • addComponentColumn

      public <V extends Component> Grid.Column<T> addComponentColumn(ValueProvider<T,V> componentProvider)
      Adds a new column that shows components.

      This is a shorthand for addColumn(Renderer) with a ComponentRenderer.

      NOTE: Using ComponentRenderer is not as efficient as the built in renderers or using LitRenderer.

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Type Parameters:
      V - the component type
      Parameters:
      componentProvider - a value provider that will return a component for the given item
      Returns:
      the new column
      See Also:
    • addColumn

      public <V extends Comparable<? super V>> Grid.Column<T> addColumn(ValueProvider<T,V> valueProvider, String... sortingProperties)
      Adds a new text column to this Grid with a value provider and sorting properties.The value is converted to a JSON value by using JsonSerializer.toJson(Object). The sorting properties are used to configure backend sorting for this column. In-memory sorting is automatically configured using the return type of the given ValueProvider.

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Type Parameters:
      V - the type of the column
      Parameters:
      valueProvider - the value provider
      sortingProperties - the sorting properties to use with this column
      Returns:
      the created column
      See Also:
    • addColumn

      public Grid.Column<T> addColumn(Renderer<T> renderer)
      Adds a new text column to this Grid with a renderer and default column factory.

      See implementations of the Renderer interface for built-in renderer options with type safe APIs. For a renderer using template binding, use LitRenderer.of(String).

      NOTE: You can add component columns easily using the addComponentColumn(ValueProvider), but using ComponentRenderer is not as efficient as the built in renderers or using LitRenderer.

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      NOTE: This method is a shorthand for addColumn(Renderer, BiFunction)

      Parameters:
      renderer - the renderer used to create the grid cell structure
      Returns:
      the created column
      See Also:
    • addColumn

      protected <C extends Grid.Column<T>> C addColumn(Renderer<T> renderer, BiFunction<Renderer<T>,String,C> columnFactory)
      Adds a new text column to this Grid with a renderer and column factory provided.

      See implementations of the Renderer interface for built-in renderer options with type safe APIs. For a renderer using template binding, use LitRenderer.of(String).

      NOTE: You can add component columns easily using the addComponentColumn(ValueProvider), but using ComponentRenderer is not as efficient as the built in renderers or using LitRenderer.

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Parameters:
      renderer - the renderer used to create the grid cell structure
      columnFactory - the method that creates a new column instance for this Grid instance.
      Returns:
      the created column
      See Also:
    • createColumn

      @Deprecated protected Grid.Column<T> createColumn(Renderer<T> renderer, String columnId)
      Deprecated.
      This method should not be used outside. getDefaultColumnFactory() should be used instead.
      Creates a new column instance for this Grid instance.

      This method must not return null.

      Parameters:
      renderer - the renderer used to create the grid cell structure
      columnId - internal column id
      Returns:
      column instance
      See Also:
    • getDefaultColumnFactory

      protected BiFunction<Renderer<T>,String,Grid.Column<T>> getDefaultColumnFactory()
      Gives a reference to the column factory.

      This method must not return null.

      Returns:
      method for column creation
    • addColumn

      public Grid.Column<T> addColumn(String propertyName)
      Adds a new column for the given property name with the default column factory. The property values are converted to Strings in the grid cells. The property's full name will be used as the column key and the property caption will be used as the column header.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      If the property is Comparable, the created column is sortable by default. This can be changed with the Grid.Column.setSortable(boolean) method.

      Note: This method can only be used for a Grid created from a bean type with Grid(Class).

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Note: This method is a shorthand for addColumn(String, BiFunction)

      Parameters:
      propertyName - the property name of the new column, not null
      Returns:
      the created column
      See Also:
    • addColumn

      protected <C extends Grid.Column<T>> C addColumn(String propertyName, BiFunction<Renderer<T>,String,C> columnFactory)
      Adds a new column for the given property name with the column factory provided. The property values are converted to Strings in the grid cells. The property's full name will be used as the column key and the property caption will be used as the column header.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      If the property is Comparable, the created column is sortable by default. This can be changed with the Grid.Column.setSortable(boolean) method.

      Note: This method can only be used for a Grid created from a bean type with Grid(Class).

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Parameters:
      propertyName - the property name of the new column, not null
      columnFactory - the method that creates a new column instance for this Grid instance.
      Returns:
      the created column
      See Also:
    • addColumns

      public void addColumns(String... propertyNames)
      Adds a new columns for the given property names. The property values are converted to Strings in the grid cells. The properties' full names will be used as the column key and the properties' caption will be used as the column header.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      If the property is Comparable, the created column is sortable by default. This can be changed with the Grid.Column.setSortable(boolean) method.

      Note: This method can only be used for a Grid created from a bean type with Grid(Class).

      Every added column sends data to the client side regardless of its visibility state. Don't add a new column at all or use removeColumn(Column) to avoid sending extra data.

      Parameters:
      propertyNames - the property names of the new columns, not null
      See Also:
    • setColumns

      public void setColumns(String... propertyNames)
      Sets the columns and their order based on the given properties.

      This is a shortcut for removing all columns and then calling addColumn(String) for each of the given propertyNames.

      You can add columns for nested properties with dot notation, eg. "property.nestedProperty"

      Note that this also resets the headers and footers.

      Note: This method can only be used for a Grid created from a bean type with Grid(Class).

      Parameters:
      propertyNames - the properties to create columns for
    • setSortableColumns

      public void setSortableColumns(String... propertyNames)
      Sets the defined columns as sortable, based on the given property names.

      This is a shortcut for setting all columns not sortable and then calling Grid.Column.setSortable(boolean) for each of the columns defined by the given propertyNames.

      You can set sortable columns for nested properties with dot notation, eg. "property.nestedProperty"

      Note: This method can only be used for a Grid created from a bean type with Grid(Class).

      Parameters:
      propertyNames - the property names used to reference the columns
      Throws:
      IllegalArgumentException - if any of the propertyNames refers to a non-existing column
      See Also:
    • setColumnKey

      protected void setColumnKey(String key, Grid.Column column)
      Sets a user-defined identifier for given column.
      Parameters:
      column - the column
      key - the user-defined identifier
      See Also:
    • createColumnId

      protected String createColumnId(boolean increment)
    • prependHeaderRow

      public HeaderRow prependHeaderRow()
      Adds a new header row on the top of the existing header rows.

      If there are no existing header rows, this will create the first row.

      Returns:
      the created header row
    • appendHeaderRow

      public HeaderRow appendHeaderRow()
      Adds a new header row to the bottom of the existing header rows.

      If there are no existing header rows, this will create the first row.

      Returns:
      the created header row
    • addFirstHeaderRow

      protected HeaderRow addFirstHeaderRow()
    • getDefaultHeaderRow

      protected HeaderRow getDefaultHeaderRow()
    • prependFooterRow

      public FooterRow prependFooterRow()
      Adds a new footer row on the top of the existing footer rows.

      If there are no existing footer rows, this will create the first row.

      Returns:
      the created footer row
    • appendFooterRow

      public FooterRow appendFooterRow()
      Adds a new footer row to the bottom of the existing footer rows.

      If there are no existing footer rows, this will create the first row.

      Returns:
      the created header row
    • getColumnLayers

      protected List<com.vaadin.flow.component.grid.ColumnLayer> getColumnLayers()
    • getHeaderRows

      public List<HeaderRow> getHeaderRows()
      Gets all of the header rows in the Grid, in order from top to bottom.
      Returns:
      the header rows of the Grid
    • getFooterRows

      public List<FooterRow> getFooterRows()
      Gets all of the footer rows in the Grid, in order from top to bottom.
      Returns:
      the footer rows of the Grid
    • addThemeVariants

      public void addThemeVariants(GridVariant... variants)
      Adds theme variants to the component.
      Parameters:
      variants - theme variants to add
    • removeThemeVariants

      public void removeThemeVariants(GridVariant... variants)
      Removes theme variants from the component.
      Parameters:
      variants - theme variants to remove
    • insertColumnLayer

      protected com.vaadin.flow.component.grid.ColumnLayer insertColumnLayer(int index, List<com.vaadin.flow.component.grid.AbstractColumn<?>> columns)
      Creates a new layer from the provided columns, inserts the layer into given index and returns the new layer.

      The user of this method should make sure that the DOM corresponds the column layer structure.

      Parameters:
      index - the index to insert
      columns - the column components that the new layer will wrap
      Returns:
      the new layer
    • removeColumnLayer

      protected void removeColumnLayer(com.vaadin.flow.component.grid.ColumnLayer layer)
      Removes the given layer and moves the columns on the lower level to its place.
      Parameters:
      layer - the layer to remove, not the bottom layer
    • setDataProvider

      public void setDataProvider(DataProvider<T,?> dataProvider)
      Sets a generic data provider for the Grid to use.

      Use this method when none of the setItems methods are applicable, e.g. when having a data provider with filter that cannot be transformed to DataProvider<T, Void>.

      Parameters:
      dataProvider - DataProvider instance to use, not null
    • getDataProvider

      public DataProvider<T,?> getDataProvider()
      Returns the data provider of this grid.

      To get information and control over the items in the grid, use either getListDataView() or getLazyDataView() instead.

      Returns:
      the data provider of this grid, not null
    • setItems

      public GridDataView<T> setItems(DataProvider<T,Void> dataProvider)
      Description copied from interface: HasDataView
      Set a generic data provider for the component to use and returns the base DataView that provides API to get information on the items.

      This method should be used only when the data provider type is not either ListDataProvider or BackEndDataProvider.

      Specified by:
      setItems in interface HasDataView<T,Void,GridDataView<T>>
      Parameters:
      dataProvider - DataProvider instance to use, not null
      Returns:
      DataView providing information on the data
    • setItems

      public GridDataView<T> setItems(InMemoryDataProvider<T> inMemoryDataProvider)
      Description copied from interface: HasDataView
      Sets an in-memory data provider for the component to use

      Note! Using a ListDataProvider instead of a InMemoryDataProvider is recommended to get access to ListDataView API by using HasListDataView.setItems(ListDataProvider).

      Specified by:
      setItems in interface HasDataView<T,Void,GridDataView<T>>
      Parameters:
      inMemoryDataProvider - InMemoryDataProvider to use, not null
      Returns:
      DataView providing information on the data
    • getGenericDataView

      public GridDataView<T> getGenericDataView()
      Gets the generic data view for the grid. This data view should only be used when getListDataView() or getLazyDataView() is not applicable for the underlying data provider.
      Specified by:
      getGenericDataView in interface HasDataView<T,Void,GridDataView<T>>
      Returns:
      the generic DataView implementation for grid
      See Also:
    • setItems

      public GridListDataView<T> setItems(ListDataProvider<T> dataProvider)
      Description copied from interface: HasListDataView
      Sets a ListDataProvider for the component to use and returns a ListDataView that provides information and allows operations on the items.
      Specified by:
      setItems in interface HasListDataView<T,GridListDataView<T>>
      Parameters:
      dataProvider - ListDataProvider providing items to the component.
      Returns:
      ListDataView providing access to the items
    • getListDataView

      public GridListDataView<T> getListDataView()
      Gets the list data view for the grid. This data view should only be used when the items are in-memory set with: If the items are not in-memory an exception is thrown. When the items are fetched lazily, use getLazyDataView() instead.
      Specified by:
      getListDataView in interface HasListDataView<T,GridListDataView<T>>
      Returns:
      the list data view that provides access to the items in the grid
    • setItems

      public GridLazyDataView<T> setItems(BackEndDataProvider<T,Void> dataProvider)
      Description copied from interface: HasLazyDataView
      Supply items with a BackEndDataProvider that lazy loads items from a backend. Note that component will query the data provider for the item count. In case that is not desired for performance reasons, use HasLazyDataView.setItems(CallbackDataProvider.FetchCallback) instead.

      The returned data view object can be used for further configuration, or later on fetched with HasLazyDataView.getLazyDataView(). For using in-memory data, like Collection, use HasListDataView.setItems(Collection) instead.

      Specified by:
      setItems in interface HasLazyDataView<T,Void,GridLazyDataView<T>>
      Parameters:
      dataProvider - BackEndDataProvider instance
      Returns:
      LazyDataView instance for further configuration
    • getLazyDataView

      public GridLazyDataView<T> getLazyDataView()
      Gets the lazy data view for the grid. This data view should only be used when the items are provided lazily from the backend with: If the items are not fetched lazily an exception is thrown. When the items are in-memory, use getListDataView() instead.
      Specified by:
      getLazyDataView in interface HasLazyDataView<T,Void,GridLazyDataView<T>>
      Returns:
      the lazy data view that provides access to the data bound to the grid
    • getDataCommunicator

      public DataCommunicator<T> getDataCommunicator()
      Returns the data communicator of this Grid.
      Returns:
      the data communicator, not null
    • getPageSize

      public int getPageSize()
      Gets the current page size, which is the number of items fetched at a time from the dataprovider.
      Returns:
      the current page size
    • setPageSize

      public void setPageSize(int pageSize)
      Sets the page size, which is the number of items fetched at a time from the data provider. With the default value of 50, the grid might fetch items for example as: 0-49, 50-149, 150-200....

      Note: the number of items in the server-side memory can be considerably higher than the page size, since the component can show more than one page at a time.

      Setting the pageSize after the Grid has been rendered effectively resets the component, and the current page(s) and sent over again.

      With automatically extending grid, controlling the item count and how much it is increased when scrolling is possible via getLazyDataView().

      Parameters:
      pageSize - the maximum number of items sent per request. Should be greater than zero
    • getSelectionModel

      public GridSelectionModel<T> getSelectionModel()
      Returns the selection model for this grid.
      Returns:
      the selection model, not null
    • setSelectionModel

      protected void setSelectionModel(GridSelectionModel<T> model, Grid.SelectionMode selectionMode)
      Sets the selection model for the grid.

      This method is for setting a custom selection model, and is protected because setSelectionMode(SelectionMode) should be used for easy switching between built-in selection models.

      The default selection model is GridSingleSelectionModel.

      To use a custom selection model, you can e.g. extend the grid call this method with your custom selection model.

      Parameters:
      model - the selection model to use, not null
      selectionMode - the selection mode this selection model corresponds to, not null
      See Also:
    • updateSelectionModeOnClient

      protected void updateSelectionModeOnClient()
    • setSelectionMode

      public GridSelectionModel<T> setSelectionMode(Grid.SelectionMode selectionMode)
      Sets the grid's selection mode.

      To use your custom selection model, you can use setSelectionModel(GridSelectionModel, SelectionMode), see existing selection model implementations for example.

      Parameters:
      selectionMode - the selection mode to switch to, not null
      Returns:
      the used selection model
      See Also:
    • asSingleSelect

      public SingleSelect<Grid<T>,T> asSingleSelect()
      Use this grid as a single select in Binder.

      Throws IllegalStateException if the grid is not using a GridSingleSelectionModel.

      Returns:
      the single select wrapper that can be used in binder
      Throws:
      IllegalStateException - if not using a single selection model
    • asMultiSelect

      public MultiSelect<Grid<T>,T> asMultiSelect()
      Use this grid as a multiselect in Binder.

      Throws IllegalStateException if the grid is not using a GridMultiSelectionModel.

      Returns:
      the multiselect wrapper that can be used in binder
      Throws:
      IllegalStateException - if not using a multiselection model
    • getSelectedItems

      public Set<T> getSelectedItems()
      This method is a shorthand that delegates to the currently set selection model.
      Returns:
      a set with the selected items, never null
      See Also:
    • select

      public void select(T item)
      This method is a shorthand that delegates to the currently set selection model.
      Parameters:
      item - the item to select, not null
      See Also:
    • deselect

      public void deselect(T item)
      This method is a shorthand that delegates to the currently set selection model.
      Parameters:
      item - the item to deselect, not null
      See Also:
    • deselectAll

      public void deselectAll()
      This method is a shorthand that delegates to the currently set selection model.
      See Also:
    • addSelectionListener

      public Registration addSelectionListener(SelectionListener<Grid<T>,T> listener)
      Adds a selection listener to the current selection model.

      This is a shorthand for grid.getSelectionModel().addSelectionListener(). To get more detailed selection events, use getSelectionModel() and either GridSingleSelectionModel.addSingleSelectionListener(SingleSelectionListener) or GridMultiSelectionModel.addMultiSelectionListener(MultiSelectionListener) depending on the used selection mode.

      Parameters:
      listener - the listener to add
      Returns:
      a registration handle to remove the listener
      Throws:
      UnsupportedOperationException - if selection has been disabled with Grid.SelectionMode.NONE
    • setItemDetailsRenderer

      public void setItemDetailsRenderer(Renderer<T> renderer)
      Set the renderer to use for displaying the item details rows in this grid.
      Parameters:
      renderer - the renderer to use for displaying item details rows, null to remove the current renderer
    • isColumnReorderingAllowed

      @Synchronize("column-reordering-allowed-changed") public boolean isColumnReorderingAllowed()
      Returns whether column reordering is allowed. Default value is false.
      Returns:
      true if reordering is allowed
    • setColumnReorderingAllowed

      public void setColumnReorderingAllowed(boolean columnReorderingAllowed)
      Sets whether or not column reordering is allowed. Default value is false.
      Parameters:
      columnReorderingAllowed - specifies whether column reordering is allowed
    • getColumns

      public List<Grid.Column<T>> getColumns()
      Gets an unmodifiable list of all Grid.Columns currently in this Grid.

      Note: If column reordering is enabled with setColumnReorderingAllowed(boolean) and the user has reordered the columns, the order of the list returned by this method might be incorrect.

      Returns:
      unmodifiable list of columns
    • getColumnByKey

      public Grid.Column<T> getColumnByKey(String columnKey)
      Gets a Grid.Column of this grid by its key.
      Parameters:
      columnKey - the identifier key of the column to get
      Returns:
      the column corresponding to the given column key, or null if no column has such key
      See Also:
    • removeColumnByKey

      public void removeColumnByKey(String columnKey)
      Removes a column with the given column key from the Grid.
      Parameters:
      columnKey - the key of the column, assigned by Grid.Column.setKey(String), or automatically created when using Grid(Class). Cannot be null
      Throws:
      IllegalArgumentException - if the column is not part of this Grid
    • removeColumn

      public void removeColumn(Grid.Column<T> column)
      Removes a column from the Grid.
      Parameters:
      column - the column to be removed, not null
      Throws:
      NullPointerException - if the column is null
      IllegalArgumentException - if the column is not owned by this Grid
    • removeColumns

      public void removeColumns(Grid.Column<T>... columns)
      Removes columns from the Grid. Does nothing if the array is empty.
      Parameters:
      columns - the columns to be removed, not null
      Throws:
      NullPointerException - if the column is null
      IllegalArgumentException - if the column is not owned by this Grid
    • removeAllColumns

      public void removeAllColumns()
      Removes all columns from this Grid.
    • setDetailsVisible

      public void setDetailsVisible(T item, boolean visible)
      Sets the visibility of details component for given item.
      Parameters:
      item - the item to show details for
      visible - true if details component should be visible; false if it should be hidden
    • setDetailsVisibleOnClick

      public void setDetailsVisibleOnClick(boolean detailsVisibleOnClick)
      Sets whether the item details can be opened and closed by clicking the rows or not.
      Parameters:
      detailsVisibleOnClick - true to enable opening and closing item details by clicking the rows, false to disable this functionality
      See Also:
    • isDetailsVisibleOnClick

      public boolean isDetailsVisibleOnClick()
      Gets whether the item details are opened and closed by clicking the rows or not.
      Returns:
      true if clicking the rows opens and closes their item details, false otherwise
      See Also:
    • isDetailsVisible

      public boolean isDetailsVisible(T item)
      Returns the visibility of details component for given item.
      Parameters:
      item - the item to show details for
      Returns:
      true if details component should be visible; false if it should be hidden
    • addSortListener

      public Registration addSortListener(ComponentEventListener<SortEvent<Grid<T>,GridSortOrder<T>>> listener)
      Description copied from interface: SortEvent.SortNotifier
      Adds a sort order change listener that gets notified when the sort order changes.
      Specified by:
      addSortListener in interface SortEvent.SortNotifier<Grid<T>,GridSortOrder<T>>
      Parameters:
      listener - the sort order change listener to add
      Returns:
      a registration object for removing the listener
    • setMultiSort

      public void setMultiSort(boolean multiSort)
      Sets whether multiple column sorting is enabled on the client-side.
      Parameters:
      multiSort - true to enable sorting of multiple columns on the client-side, false to disable
    • setMultiSort

      public void setMultiSort(boolean multiSort, Grid.MultiSortPriority priority)
      Sets whether multiple column sorting is enabled on the client-side.
      Parameters:
      multiSort - true to enable sorting of multiple columns on the client-side, false to disable
      priority - the multi-sort priority to set, not null
      See Also:
    • setMultiSort

      public void setMultiSort(boolean multiSort, boolean onShiftClickOnly)
      Sets whether multiple column sorting is enabled on the client-side.
      Parameters:
      multiSort - true to enable sorting of multiple columns on the client-side, false to disable
      onShiftClickOnly - true to enable multi-sort by shift-clicking (when multiSort = true), false for normal multi-sort behavior
    • setMultiSort

      public void setMultiSort(boolean multiSort, Grid.MultiSortPriority priority, boolean onShiftClickOnly)
      Sets whether multiple column sorting is enabled on the client-side.
      Parameters:
      multiSort - true to enable sorting of multiple columns on the client-side, false to disable
      priority - the multi-sort priority to set, not null
      onShiftClickOnly - true to enable multi-sort by shift-clicking (when multiSort = true), false for normal multi-sort behavior
      See Also:
    • isMultiSort

      public boolean isMultiSort()
      Gets whether multiple column sorting is enabled on the client-side.
      Returns:
      true if sorting of multiple columns is enabled, false otherwise
      See Also:
    • addContextMenu

      public GridContextMenu<T> addContextMenu()
      Adds a new context-menu for this grid.
      Returns:
      the added context-menu
    • sort

      public void sort(List<GridSortOrder<T>> order)
      Forces a defined sort order for the columns in the Grid. Setting null or an empty list resets the ordering of all columns. Columns not mentioned in the list are reset to the unsorted state.

      For Grids with multi-sorting, the index of a given column inside the list defines the sort priority. For example, the column at index 0 of the list is sorted first, then on the index 1, and so on.

      When Grid is not configured to have multi-sorting enabled, all the columns in the list except the first one are ignored.

      Parameters:
      order - the list of sort orders to set on the client, or null to reset any sort orders.
      See Also:
    • onAttach

      protected void onAttach(AttachEvent attachEvent)
      Description copied from class: Component
      Called when the component is attached to a UI.

      The default implementation does nothing.

      This method is invoked before the AttachEvent is fired for the component.

      Overrides:
      onAttach in class Component
      Parameters:
      attachEvent - the attach event
    • onDetach

      protected void onDetach(DetachEvent detachEvent)
      Description copied from class: Component
      Called when the component is detached from a UI.

      The default implementation does nothing.

      This method is invoked before the DetachEvent is fired for the component.

      Overrides:
      onDetach in class Component
      Parameters:
      detachEvent - the detach event
    • getSortOrder

      public List<GridSortOrder<T>> getSortOrder()
      Gets an list of the current sort orders in the Grid.
      Returns:
      an unmodifiable list of sort orders
    • createSortingComparator

      protected SerializableComparator<T> createSortingComparator()
      Creates a comparator for grid to sort rows.
      Returns:
      the comparator based on column sorting information.
    • setAllRowsVisible

      public void setAllRowsVisible(boolean allRowsVisible)
      If true, the grid's height is defined by its rows. All items are fetched from the DataProvider, and the Grid shows no vertical scroll bar.

      Note: setAllRowsVisible disables the grid's virtual scrolling so that all the rows are rendered in the DOM at once. If the grid has a large number of items, using the feature is discouraged to avoid performance issues.

      Parameters:
      allRowsVisible - true to make Grid compute its height by the number of rows, false for the default behavior
    • isAllRowsVisible

      @Synchronize("all-rows-visible-changed") public boolean isAllRowsVisible()
      Gets whether grid's height is defined by the number of its rows.
      Returns:
      true if Grid computes its height by the number of rows, false otherwise
    • onEnabledStateChanged

      public void onEnabledStateChanged(boolean enabled)
      Description copied from class: Component
      Handle component enable state when the enabled state changes.

      By default this sets or removes the 'disabled' attribute from the element. This can be overridden to have custom handling.

      Overrides:
      onEnabledStateChanged in class Component
      Parameters:
      enabled - the new enabled state of the component
    • addValueProvider

      public Registration addValueProvider(String property, ValueProvider<T,?> valueProvider)
      Adds a ValueProvider to this Grid that is not tied to a Column. This is specially useful when the columns are defined via a template file instead of the Java API.

      The properties added to by this method are global to the Grid - they can be used in any column.

      ValueProviders are registered as DataGenerators in the Grid. See addDataGenerator(DataGenerator).

      Parameters:
      property - the property name used in the template. For example, in a template the uses [[item.name]], the property is name. Not null
      valueProvider - the provider for values for the property, not null
      Returns:
      a registration that can be used to remove the ValueProvider from the Grid
    • addDataGenerator

      public Registration addDataGenerator(DataGenerator<T> dataGenerator)
      Description copied from interface: HasDataGenerators
      Adds the given data generator. If the generator was already added, does nothing.
      Specified by:
      addDataGenerator in interface HasDataGenerators<T>
      Parameters:
      dataGenerator - the data generator to add
      Returns:
      a registration that can be used to remove the data generator
    • compareMaybeComparables

      protected static int compareMaybeComparables(Object a, Object b)
    • configureBeanType

      public void configureBeanType(Class<T> beanType, boolean autoCreateColumns)
      Sets the bean type this grid is bound to and optionally adds a set of columns for each of the bean's properties. The property-values of the bean will be converted to Strings. Full names of the properties will be used as the column keys and the property captions will be used as the column headers. The generated columns will be sortable by default, if the property is Comparable.

      When autoCreateColumns is true, only the direct properties of the bean are included and they will be in alphabetical order. Use setColumns(String...) to define which properties to include and in which order. You can also add a column for an individual property with addColumn(String). Both of these methods support also sub-properties with dot-notation, eg. "property.nestedProperty".

      This method can only be called for a newly instanced Grid without any beanType or columns set.

      Parameters:
      beanType - the bean type to use, not null
      autoCreateColumns - when true, columns are created automatically for the properties of the beanType
    • getBeanType

      public Class<T> getBeanType()
      Returns the Class of bean this Grid is constructed with via Grid(Class). Or null if not constructed from a bean type.
      Returns:
      the Class of bean this Grid is constructed with
    • getPropertySet

      public PropertySet<T> getPropertySet()
      Returns PropertySet of bean this Grid is constructed with via Grid(Class). Or null if not constructed from a bean type.
      Returns:
      the PropertySet of bean this Grid is constructed with
    • addItemClickListener

      public Registration addItemClickListener(ComponentEventListener<ItemClickEvent<T>> listener)
      Adds an item click listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
      See Also:
    • addColumnResizeListener

      public Registration addColumnResizeListener(ComponentEventListener<ColumnResizeEvent<T>> listener)
      Adds a column resize listener to this component. Note that the listener will be notified only for user-initiated column resize actions.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addItemDoubleClickListener

      public Registration addItemDoubleClickListener(ComponentEventListener<ItemDoubleClickEvent<T>> listener)
      Adds an item double click listener to this component.

      Note that double click event happens along with a click event. It means there is no way to get a double click event only (double click without a click): a click listener added using addItemClickListener(ComponentEventListener) (if any) will also be notified about a click event once a double click event is fired.

      Double click event type is not fully supported by the mobile browsers which means that double click event might not work (double click listeners won't be notified) for such browsers.

      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
      See Also:
    • addCellFocusListener

      public Registration addCellFocusListener(ComponentEventListener<CellFocusEvent<T>> listener)
      Adds a listener to the grid that will be notified, when a cell has been focused.

      The listener will be notified, when
      • the navigation focus of a cell gets activated
      • the focus is restored to the browser if a cell had navigation focus before the focus was lost
      • the navigation focus moves between header/body/footer sections

      The listener will not be notified, when
      • the focus changes between focusable elements in the Grid cells ("interaction mode")
      • on Grid Pro edit mode navigation ("interaction mode")
      • the focus changes between focusable elements in the cells in Flow Grid's editor mode ("interaction mode")
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • getEditor

      public Editor<T> getEditor()
      Gets the editor.

      The editor is created using createEditor().

      Returns:
      the editor instance
      See Also:
    • setClassNameGenerator

      public void setClassNameGenerator(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. Returning 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.

      Parameters:
      classNameGenerator - the class name generator to set, not null
      Throws:
      NullPointerException - if classNameGenerator is null
      See Also:
    • setPartNameGenerator

      public void setPartNameGenerator(SerializableFunction<T,String> partNameGenerator)
      Sets the function that is used for generating CSS part names for all the cells in the rows in this grid. Returning null from the generator results in no custom part name being set. Multiple part names can be returned from the generator as space-separated.

      If Grid.Column.setPartNameGenerator(SerializableFunction) is used together with this method, resulting part names from both methods will be effective.

      Parameters:
      partNameGenerator - the part name generator to set, not null
      Throws:
      NullPointerException - if partNameGenerator is null
      See Also:
    • recalculateColumnWidths

      public void recalculateColumnWidths()
      Updates the width of all columns which have autoWidth set to true.
      See Also:
    • getClassNameGenerator

      public SerializableFunction<T,String> getClassNameGenerator()
      Gets the function that is used for generating CSS class names for rows in this grid.
      Returns:
      the class name generator
    • getPartNameGenerator

      public SerializableFunction<T,String> getPartNameGenerator()
      Gets the function that is used for generating CSS part names for rows in this grid.
      Returns:
      the part name generator
    • createEditor

      protected Editor<T> createEditor()
      Creates a new Editor instance. Can be overridden to create a custom Editor. If the Editor is a Grid.AbstractGridExtension, it will be automatically added to DataCommunicator.
      Returns:
      editor
    • getUniqueKeyProvider

      protected ValueProvider<T,String> getUniqueKeyProvider()
      Gets optional value provider for unique key in row's generated JSON.
      Returns:
      ValueProvider for unique key for row or null if not set
    • setUniqueKeyProvider

      protected void setUniqueKeyProvider(ValueProvider<T,String> uniqueKeyProvider)
      Sets value provider for unique key in row's generated JSON.

      null by default.

      Parameters:
      uniqueKeyProvider - ValueProvider for unique key for row
    • getUniqueKeyProperty

      protected String getUniqueKeyProperty()
      Gets property name for unique key in row's generated JSON.
      Returns:
      the optional property name for unique key
    • setUniqueKeyProperty

      protected void setUniqueKeyProperty(String uniqueKeyProperty)
      Sets property name for unique key in row's generated JSON.
      Parameters:
      uniqueKeyProperty - the new optional property name for unique key
    • getArrayUpdater

      protected GridArrayUpdater getArrayUpdater()
    • onDataProviderChange

      protected void onDataProviderChange()
      Callback which is called if a new data provider is set or any change happen in the current data provider (an DataChangeEvent event is fired). Default implementation closes the editor if it's opened.
      See Also:
    • addDropListener

      public Registration addDropListener(ComponentEventListener<GridDropEvent<T>> listener)
      Adds a drop listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addDragStartListener

      public Registration addDragStartListener(ComponentEventListener<GridDragStartEvent<T>> listener)
      Adds a drag start listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • addDragEndListener

      public Registration addDragEndListener(ComponentEventListener<GridDragEndEvent<T>> listener)
      Adds a drag end listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • setDropMode

      public void setDropMode(GridDropMode dropMode)
      Sets the drop mode of this drop target. When set to not null, grid fires drop events upon data drop over the grid or the grid rows.

      When using GridDropMode.ON_TOP, and the grid is either empty or has empty space after the last row, the drop can still happen on the empty space, and the GridDropEvent.getDropTargetItem() will return an empty optional.

      When using GridDropMode.BETWEEN or GridDropMode.ON_TOP_OR_BETWEEN, and there is at least one row in the grid, any drop after the last row in the grid will get the last row as the GridDropEvent.getDropTargetItem(). If there are no rows in the grid, then it will return an empty optional.

      If using GridDropMode.ON_GRID, then the drop will not happen on any row, but instead just "on the grid". The target row will not be present in this case.

      NOTE: Prefer not using a row specific GridDropMode with a grid that enables sorting. If for example a new row gets added to a specific location on drop event, it might not end up in the location of the drop but rather where the active sorting configuration prefers to place it. This behavior might feel unexpected for the users.

      Parameters:
      dropMode - Drop mode that describes the allowed drop locations within the Grid's row. Can be null to disable dropping on the grid.
      See Also:
    • getDropMode

      public GridDropMode getDropMode()
      Gets the drop mode of this drop target.
      Returns:
      Drop mode that describes the allowed drop locations within the Grid's row. null if dropping is not enabled.
    • setRowsDraggable

      public void setRowsDraggable(boolean rowsDraggable)
      Sets whether the user can drag the grid rows or not.
      Parameters:
      rowsDraggable - true if the rows can be dragged by the user; false if not
    • isRowsDraggable

      public boolean isRowsDraggable()
      Gets whether rows of the grid can be dragged.
      Returns:
      true if the rows are draggable, false otherwise
    • getDropFilter

      public SerializablePredicate<T> getDropFilter()
      Gets the active drop filter.
      Returns:
      The drop filter function
    • getDragFilter

      public SerializablePredicate<T> getDragFilter()
      Gets the active drag filter.
      Returns:
      The drag filter function
    • setDropFilter

      public void setDropFilter(SerializablePredicate<T> dropFilter)
      Sets the drop filter for this drag target.

      When the drop mode of the grid has been set to one of GridDropMode.BETWEEN, GridDropMode.ON_TOP or GridDropMode.ON_TOP_OR_BETWEEN, by default all the visible rows can be dropped over.

      A drop filter function can be used to specify the rows that are available for dropping over. The function receives an item and should return true if the row can be dropped over, false otherwise.

      NOTE: If the filter conditions depend on a specific row that's currently being dragged, you might want to have the grid's drop mode disabled by default and set its value only on drag start to avoid the small period of time during which the user might be able to drop over unwanted rows. Once the drop end event occurs, the drop mode can be set back to null to keep this consistent.

      NOTE: If the filtering conditions change dynamically, remember to explicitly invoke getDataProvider().refreshItem(item) for the relevant items to get the filters re-run for them.

    • setDragFilter

      public void setDragFilter(SerializablePredicate<T> dragFilter)
      Sets the drag filter for this drag source.

      When the setRowsDraggable(boolean) has been used to enable dragging, by default all the visible rows can be dragged.

      A drag filter function can be used to specify the rows that are available for dragging. The function receives an item and returns true if the row can be dragged, false otherwise.

      NOTE: If the filtering conditions change dynamically, remember to explicitly invoke getDataProvider().refreshItem(item) for the relevant items to get the filters re-run for them.

    • setDragDataGenerator

      public void setDragDataGenerator(String type, SerializableFunction<T,String> dragDataGenerator)
      Sets a generator function for customizing drag data. The generated value will be accessible using the same type as the generator is set here. The function is executed for each item in the Grid during data generation. Return a String to be appended to the row as type data.

      Note that IE11 only supports data type "text"

      Parameters:
      type - Type of the generated data. The generated value will be accessible during drop using this type.
      dragDataGenerator - Function to be executed on row data generation.
    • setTooltipGenerator

      public void setTooltipGenerator(SerializableFunction<T,String> tooltipGenerator)
      Sets the function that is used for generating tooltip text for all cells in this grid. Tooltip generators set to individual columns have priority over the generator set with this method. Returning null from the generator results in no tooltip being set.
      Parameters:
      tooltipGenerator - the tooltip generator to set, not null
      Throws:
      NullPointerException - if tooltipGenerator is null
      Since:
      24.1
    • setSelectionDragDetails

      public void setSelectionDragDetails(int draggedItemsCount, Map<String,String> dragData)
      Sets explicit drag operation details for when the user is dragging the selected items. By default, the drag data only covers the items in the visible viewport and all the items outside of it, even if selected, are excluded. Use this method to override the default drag data and the number shown in drag image on selection drag.

      Note that IE11 only supports data type "text"

      Parameters:
      draggedItemsCount - The number shown in the drag image on selection drag. Only values above 1 have any visible effect.
      dragData - The drag data for selection drag. The map should consist of data type:data -entries
    • addColumnReorderListener

      public Registration addColumnReorderListener(ComponentEventListener<ColumnReorderEvent<T>> listener)
      Adds a column reorder listener to this component.
      Parameters:
      listener - the listener to add, not null
      Returns:
      a handle that can be used for removing the listener
    • setColumnOrder

      public void setColumnOrder(Grid.Column<T>... columns)
      Sets a new column order for the grid.

      The function doesn't support column removal: all columns must be present in the list, otherwise IllegalArgumentException is thrown.

      The getColumns() function will reflect the new column ordering.

      Fires the ColumnReorderEvent with ComponentEvent.isFromClient() returning false.

      The method is atomic: if the requested reordering is not achievable, the function fails cleanly with IllegalArgumentException without doing any work.

      Parameters:
      columns - the new ordering of the columns, not null.
      Throws:
      NullPointerException - if the columns parameter is null.
      IllegalArgumentException - if a column is present two times in the list, or if the column is not owned by this Grid, or if the list doesn't contain all columns currently present in the Grid, or if the column rearranging would require to split a joined header/footer cell group.
      See Also:
    • setColumnOrder

      public void setColumnOrder(List<Grid.Column<T>> columns)
      Sets a new column order for the grid.

      The function doesn't support column removal: all columns must be present in the list, otherwise IllegalArgumentException is thrown.

      The getColumns() function will reflect the new column ordering.

      Fires the ColumnReorderEvent with ComponentEvent.isFromClient() returning false.

      The method is atomic: if the requested reordering is not achievable, the function fails cleanly with IllegalArgumentException without doing any work.

      Parameters:
      columns - the new ordering of the columns, not null.
      Throws:
      NullPointerException - if the columns parameter is null.
      IllegalArgumentException - if a column is present two times in the list, or if the column is not owned by this Grid, or if the list doesn't contain all columns currently present in the Grid, or if the column rearranging would require to split a joined header/footer cell group.
      See Also:
    • scrollToIndex

      public void scrollToIndex(int rowIndex)
      Scrolls to the given row index. Scrolls so that the row is shown at the start of the visible area whenever possible. If the index parameter exceeds current item set size the grid will scroll to the end.
      Parameters:
      rowIndex - zero based index of the item to scroll to in the current view.
    • scrollToStart

      public void scrollToStart()
      Scrolls to the beginning of the first data row.
    • scrollToEnd

      public void scrollToEnd()
      Scrolls to the last data row of the grid.
    • setNestedNullBehavior

      public void setNestedNullBehavior(Grid.NestedNullBehavior nestedNullBehavior)
      Set the behavior when facing nested null values. By default the value is NestedNullBehavior.THROW.
      Parameters:
      nestedNullBehavior - the behavior when facing nested null values.
    • getNestedNullBehavior

      public Grid.NestedNullBehavior getNestedNullBehavior()
      Get the behavior when facing nested null values.
      Returns:
      The current behavior when facing nested null values.
    • setColumnRendering

      public void setColumnRendering(ColumnRendering columnRendering)
      Sets the mode for rendering columns in the grid.

      eager (default): All columns are rendered upfront, regardless of their visibility within the viewport. This mode should generally be preferred, as it avoids the limitations imposed by the "lazy" mode. Use this mode unless the grid has a large number of columns and performance outweighs the limitations in priority.

      lazy: Optimizes the rendering of cells when there are multiple columns in the grid by virtualizing horizontal scrolling. In this mode, body cells are rendered only when their corresponding columns are inside the visible viewport.

      Using "lazy" rendering should be used only if you're dealing with a large number of columns and performance is your highest priority. For most use cases, the default "eager" mode is recommended due to the limitations imposed by the "lazy" mode.

      When using the "lazy" mode, keep the following limitations in mind:

      • Row Height: When only a number of columns are visible at once, the height of a row can only be that of the highest cell currently visible on that row. Make sure each cell on a single row has the same height as all other cells on that row. If row cells have different heights, users may experience jumpiness when scrolling the grid horizontally as lazily rendered cells with different heights are scrolled into view.
      • Auto-width Columns: For the columns that are initially outside the visible viewport but still use auto-width, only the header content is taken into account when calculating the column width because the body cells of the columns outside the viewport are not initially rendered.
      • Screen Reader Compatibility: Screen readers may not be able to associate the focused cells with the correct headers when only a subset of the body cells on a row is rendered.
      • Keyboard Navigation: Tabbing through focusable elements inside the grid body may not work as expected because some of the columns that would include focusable elements in the body cells may be outside the visible viewport and thus not rendered.
      Parameters:
      columnRendering - the column rendering mode to use
      See Also:
    • getColumnRendering

      public ColumnRendering getColumnRendering()
      Gets the current column rendering mode.
      Returns:
      the current column rendering mode