com.vaadin.ui.

Class Grid<T>

    • Constructor Detail

      • Grid

        public Grid()

        Creates a new grid without support for creating columns based on property names. Use an alternative constructor, such as Grid(Class), to create a grid that automatically sets up columns based on the type of presented data.

        See Also:

        Grid(Class), withPropertySet(PropertySet)

      • Grid

        protected Grid​(Class<T> beanType,
                       DataCommunicator<T> dataCommunicator)

        Creates a new grid that uses custom data communicator and provided bean type It uses reflection of the provided bean type to automatically set up an initial set of columns. All columns will be configured using the same Object.toString() renderer that is used by addColumn(ValueProvider).

        Parameters:

        beanType - the bean type to use, not null

        dataCommunicator - the data communicator to use, notnull

        Since:

        8.0.7

      • Grid

        protected Grid​(DataCommunicator<T> dataCommunicator)

        Creates a new grid with the given data communicator and without support for creating columns based on property names.

        Parameters:

        dataCommunicator - the custom data communicator to set

        Since:

        8.0.7

        See Also:

        Grid(), Grid(PropertySet, DataCommunicator)

      • Grid

        public Grid​(String caption)

        Creates a new Grid using the given caption.

        Parameters:

        caption - the caption of the grid

      • Grid

        public Grid​(String caption,
                    DataProvider<T,​?> dataProvider)

        Creates a new Grid using the given caption and DataProvider.

        Parameters:

        caption - the caption of the grid

        dataProvider - the data provider, not null

      • Grid

        public Grid​(DataProvider<T,​?> dataProvider)

        Creates a new Grid using the given DataProvider.

        Parameters:

        dataProvider - the data provider, not null

      • Grid

        public Grid​(String caption,
                    Collection<T> items)

        Creates a new Grid using the given caption and collection of items.

        Parameters:

        caption - the caption of the grid

        items - the data items to use, not null

    • Method Detail

      • beforeClientResponse

        public void beforeClientResponse​(boolean initial)

        Description copied from interface: ClientConnector

        Called before the shared state and RPC invocations are sent to the client. Gives the connector an opportunity to set computed/dynamic state values or to invoke last minute RPC methods depending on other component features.

        Specified by:

        beforeClientResponse in interface ClientConnector

        Overrides:

        beforeClientResponse in class AbstractComponent

        Parameters:

        initial - true if the client-side connector will be created and initialized after this method has been invoked. false if there is already an initialized client-side connector.

      • setPropertySet

        protected void setPropertySet​(PropertySet<T> propertySet)

        Sets the property set to use for this grid. Does not create or update columns in any way but will delete and re-create the editor.

        This is only meant to be called from constructors and readDesign, at a stage where it does not matter if you throw away the editor.

        Parameters:

        propertySet - the property set to use

        Since:

        8.0.3

      • getPropertySet

        protected PropertySet<T> getPropertySet()

        Returns the property set used by this grid.

        Returns:

        propertySet the property set to return

        Since:

        8.4

      • withPropertySet

        public static <BEAN> Grid<BEAN> withPropertySet​(PropertySet<BEAN> propertySet)

        Creates a grid using a custom PropertySet implementation for creating a default set of columns and for resolving property names with addColumn(String) and Grid.Column.setEditorComponent(HasValue).

        This functionality is provided as static method instead of as a public constructor in order to make it possible to use a custom property set without creating a subclass while still leaving the public constructors focused on the common use cases.

        Type Parameters:

        BEAN - the grid bean type

        Parameters:

        propertySet - the property set implementation to use, not null.

        Returns:

        a new grid using the provided property set, not null

        See Also:

        Grid(), Grid(Class)

      • getBeanType

        public Class<T> getBeanType()

        Gets the bean type used by this grid.

        The bean type is used to automatically set up a column added using a property name.

        Returns:

        the used bean type or null if no bean type has been defined

        Since:

        8.0.3

      • fireColumnVisibilityChangeEvent

        public <V> void fireColumnVisibilityChangeEvent​(Grid.Column<T,​V> column,
                                                        boolean hidden,
                                                        boolean userOriginated)

        Sends a Grid.ColumnVisibilityChangeEvent to all listeners.

        Type Parameters:

        V - the column value type

        Parameters:

        column - the column that changed its visibility

        hidden - true if the column was hidden, false if it became visible

        userOriginated - true if the event was triggered by an UI interaction, false otherwise

      • addColumn

        public Grid.Column<T,​?> addColumn​(String propertyName)

        Adds a new column with the given property name. The column will use a TextRenderer. The value is converted to a String using Object.toString(). The property name will be used as the column id and the column caption will be set based on the property definition.

        This method can only be used for a Grid created using Grid(Class) or withPropertySet(PropertySet).

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

        Parameters:

        propertyName - the property name of the new column, not null

        Returns:

        the newly added column, not null

      • addColumn

        public Grid.Column<T,​?> addColumn​(String propertyName,
                                                AbstractRenderer<? super T,​?> renderer)

        Adds a new column with the given property name and renderer. The property name will be used as the column id and the column caption will be set based on the property definition.

        This method can only be used for a Grid created using Grid(Class) or withPropertySet(PropertySet).

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

        Parameters:

        propertyName - the property name of the new column, not null

        renderer - the renderer to use, not null

        Returns:

        the newly added column, not null

      • addColumn

        public Grid.Column<T,​?> addColumn​(String propertyName,
                                                AbstractRenderer<? super T,​?> renderer,
                                                Grid.Column.NestedNullBehavior nestedNullBehavior)

        Adds a new column with the given property name and renderer. The property name will be used as the column id and the column caption will be set based on the property definition.

        This method can only be used for a Grid created using Grid(Class) or withPropertySet(PropertySet).

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

        Parameters:

        propertyName - the property name of the new column, not null

        renderer - the renderer to use, not null

        nestedNullBehavior - the behavior when

        Returns:

        the newly added column, not null

        Since:

        8.8

      • addColumn

        public <V> Grid.Column<T,​V> addColumn​(ValueProvider<T,​V> valueProvider)

        Adds a new text column to this Grid with a value provider. The column will use a TextRenderer. The value is converted to a String using Object.toString(). In-memory sorting will use the natural ordering of elements if they are mutually comparable and otherwise fall back to comparing the string representations of the values.

        Type Parameters:

        V - the column value type

        Parameters:

        valueProvider - the value provider

        Returns:

        the new column

      • addColumn

        public <V> Grid.Column<T,​V> addColumn​(ValueProvider<T,​V> valueProvider,
                                                    AbstractRenderer<? super T,​? super V> renderer)

        Adds a new column to this Grid with typed renderer and value provider.

        Type Parameters:

        V - the column value type

        Parameters:

        valueProvider - the value provider

        renderer - the column value renderer

        Returns:

        the new column

        See Also:

        AbstractRenderer

      • addColumn

        public <V,​P> Grid.Column<T,​V> addColumn​(ValueProvider<T,​V> valueProvider,
                                                            ValueProvider<V,​P> presentationProvider,
                                                            AbstractRenderer<? super T,​? super P> renderer)

        Adds a new column to this Grid with value provider, presentation provider and typed renderer.

        The presentation provider is a method that takes the value from the value provider, and maps that to a value that the renderer accepts. This feature can be used for storing a complex value in a column for editing, but providing a simplified presentation for the user when not editing.

        Type Parameters:

        V - the column value type

        P - the column presentation type

        Parameters:

        valueProvider - the value provider

        presentationProvider - the value presentation provider

        renderer - the column value renderer

        Returns:

        the new column

        Since:

        8.1

        See Also:

        AbstractRenderer

      • addComponentColumn

        public <V extends ComponentGrid.Column<T,​V> addComponentColumn​(ValueProvider<T,​V> componentProvider)

        Adds a column that shows components.

        This is a shorthand for addColumn(String) and its variants with a ComponentRenderer.

        Type Parameters:

        V - the column value type, extends component

        Parameters:

        componentProvider - a value provider that will return a component for the given item

        Returns:

        the new column

        Since:

        8.1

      • createColumn

        protected <V,​P> Grid.Column<T,​V> createColumn​(ValueProvider<T,​V> valueProvider,
                                                                  ValueProvider<V,​P> presentationProvider,
                                                                  AbstractRenderer<? super T,​? super P> renderer)

        Creates a column instance from a value provider, presentation provider and a renderer.

        Type Parameters:

        V - the column value type

        P - the column presentation type

        Parameters:

        valueProvider - the value provider

        presentationProvider - the presentation provider

        renderer - the renderer

        Returns:

        a new column instance

        Since:

        8.1

      • removeColumn

        public void removeColumn​(Grid.Column<T,​?> column)

        Removes the given column from this Grid. Note: If you have Editor with binding in this Grid to this property, you need to remove that using removeBinding method provided by Binder.

        Parameters:

        column - the column to remove

        Throws:

        IllegalArgumentException - if the column is not a valid one

      • removeAllColumns

        public void removeAllColumns()

        Removes all columns from this Grid.

        Since:

        8.0.2

      • recalculateColumnWidths

        public void recalculateColumnWidths()

        Requests that the column widths should be recalculated.

        In most cases Grid will know when column widths need to be recalculated but this method can be used to force recalculation in situations when grid does not recalculate automatically.

        Since:

        8.1.1

      • setDetailsGenerator

        public void setDetailsGenerator​(DetailsGenerator<T> generator)

        Sets the details component generator.

        Parameters:

        generator - the generator for details components

      • 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

      • 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

      • getColumns

        public List<Grid.Column<T,​?>> getColumns()

        Gets an unmodifiable collection of all columns currently in this Grid.

        Returns:

        unmodifiable collection of columns

      • getColumn

        public Grid.Column<T,​?> getColumn​(String columnId)

        Gets a Grid.Column of this grid by its identifying string. When you use the Grid constructor with bean class, the columns are initialised with columnId being the property name.

        Parameters:

        columnId - the identifier of the column to get

        Returns:

        the column corresponding to the given column identifier, or null if there is no such column

        See Also:

        Grid.Column.setId(String)

      • iterator

        public Iterator<Component> iterator()

        Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.

        The iterator is typically unmodifiable, and calls to Iterator.remove() throw an exception.

        Note that the order of the returned components it not specified.

        Specified by:

        iterator in interface HasComponents

        Specified by:

        iterator in interface Iterable<T>

        Returns:

        the component iterator.

      • setFrozenColumnCount

        public void setFrozenColumnCount​(int numberOfColumns)

        Sets the number of frozen columns in this grid. Setting the count to 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. Setting the count to -1 will also disable the selection column.

        NOTE: this count includes hidden columns in the count.

        The default value is 0.

        Parameters:

        numberOfColumns - the number of columns that should be frozen

        Throws:

        IllegalArgumentException - if the column count is less than -1 or greater than the number of visible columns

      • getFrozenColumnCount

        public int getFrozenColumnCount()

        Gets the number of frozen columns in this grid. 0 means that no data columns will be frozen, but the built-in selection checkbox column will still be frozen if it's in use. -1 means that not even the selection column is frozen.

        NOTE: this count includes hidden columns in the count.

        Returns:

        the number of frozen columns

        See Also:

        setFrozenColumnCount(int)

      • setHeightByRows

        public void setHeightByRows​(double rows)

        Sets the number of rows that should be visible in Grid's body. This method will set the height mode to be HeightMode.ROW.

        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 - if rows is zero or less

        IllegalArgumentException - if rows is infinite

        IllegalArgumentException - if rows is NaN

      • setHeightMode

        public void setHeightMode​(HeightMode heightMode)

        Defines the mode in which the Grid widget's height is calculated.

        If HeightMode.CSS is given, Grid will respect the values given via a setHeight-method, and behave as a traditional Component.

        If HeightMode.ROW is given, Grid will make sure that the body will display as many rows as getHeightByRows() defines. Note: If headers/footers are inserted or removed, the widget will resize itself to still display the required amount of rows in its body. It also takes the horizontal scrollbar into account.

        Parameters:

        heightMode - the mode in to which Grid should be set

      • setRowHeight

        public void setRowHeight​(double rowHeight)

        Sets the height of body, header and footer rows. If -1 (default), the row height is calculated based on the theme for an empty row before the Grid is displayed.

        Note that all header, body and footer rows get the same height if explicitly set. In automatic mode, each section is calculated separately based on an empty row of that type.

        Parameters:

        rowHeight - The height of a row in pixels or -1 for automatic calculation

        See Also:

        setBodyRowHeight(double), setHeaderRowHeight(double), setFooterRowHeight(double)

      • setBodyRowHeight

        public void setBodyRowHeight​(double rowHeight)

        Sets the height of a body row. If -1 (default), the row height is calculated based on the theme for an empty row before the Grid is displayed.

        Parameters:

        rowHeight - The height of a row in pixels or -1 for automatic calculation

        Since:

        8.2

      • setHeaderRowHeight

        public void setHeaderRowHeight​(double rowHeight)

        Sets the height of a header row. If -1 (default), the row height is calculated based on the theme for an empty row before the Grid is displayed.

        Parameters:

        rowHeight - The height of a row in pixels or -1 for automatic calculation

        Since:

        8.2

      • setFooterRowHeight

        public void setFooterRowHeight​(double rowHeight)

        Sets the height of a footer row. If -1 (default), the row height is calculated based on the theme for an empty row before the Grid is displayed.

        Parameters:

        rowHeight - The height of a row in pixels or -1 for automatic calculation

        Since:

        8.2

      • getBodyRowHeight

        public double getBodyRowHeight()

        Returns the current body row height. -1 if row height is in automatic calculation mode.

        Returns:

        body row height

        Since:

        8.2

      • getHeaderRowHeight

        public double getHeaderRowHeight()

        Returns the current header row height. -1 if row height is in automatic calculation mode.

        Returns:

        header row height

        Since:

        8.2

      • getFooterRowHeight

        public double getFooterRowHeight()

        Returns the current footer row height. -1 if row height is in automatic calculation mode.

        Returns:

        footer row height

        Since:

        8.2

      • setStyleGenerator

        public void setStyleGenerator​(StyleGenerator<T> styleGenerator)

        Sets the style generator that is used for generating class names for rows in this grid. Returning null from the generator results in no custom style name being set. Note: The style generator is applied only to the body cells, not to the Editor.

        Parameters:

        styleGenerator - the row style generator to set, not null

        Throws:

        NullPointerException - if styleGenerator is null

        See Also:

        StyleGenerator

      • getStyleGenerator

        public StyleGenerator<T> getStyleGenerator()

        Gets the style generator that is used for generating class names for rows.

        Returns:

        the row style generator

        See Also:

        StyleGenerator

      • setDescriptionGenerator

        public void setDescriptionGenerator​(DescriptionGenerator<T> descriptionGenerator,
                                            ContentMode contentMode)

        Sets the description generator that is used for generating descriptions for rows. This method uses the given content mode.

        Parameters:

        descriptionGenerator - the row description generator to set, or null to remove a previously set generator

        contentMode - the content mode for row tooltips

        Since:

        8.2

        See Also:

        setDescriptionGenerator(DescriptionGenerator)

      • getDescriptionGenerator

        public DescriptionGenerator<T> getDescriptionGenerator()

        Gets the description generator that is used for generating descriptions for rows.

        Returns:

        the row description generator, or null if no generator is set

      • getHeaderRow

        public HeaderRow getHeaderRow​(int index)

        Returns the header row at the given index.

        Parameters:

        index - the index of the row, where the topmost row has index zero

        Returns:

        the header row at the index

        Throws:

        IndexOutOfBoundsException - if rowIndex < 0 || rowIndex >= getHeaderRowCount()

      • getHeaderRowCount

        public int getHeaderRowCount()

        Gets the number of rows in the header section.

        Returns:

        the number of header rows

      • setHeaderVisible

        public void setHeaderVisible​(boolean headerVisible)

        Sets the visibility of the Header in this Grid.

        Parameters:

        headerVisible - true if visible; false if not

        Since:

        8.1.1

      • isHeaderVisible

        public boolean isHeaderVisible()

        Gets the visibility of the Header in this Grid.

        Returns:

        true if visible; false if not

        Since:

        8.1.1

      • getDefaultHeaderRow

        public HeaderRow getDefaultHeaderRow()

        Returns the current default row of the header.

        Returns:

        the default row or null if no default row set

        See Also:

        setDefaultHeaderRow(HeaderRow)

      • setDefaultHeaderRow

        public void setDefaultHeaderRow​(HeaderRow row)

        Sets the default row of the header. The default row is a special header row that displays column captions and sort indicators. By default Grid has a single row which is also the default row. When a header row is set as the default row, any existing cell content is replaced by the column captions.

        Parameters:

        row - the new default row, or null for no default row

        Throws:

        IllegalArgumentException - if the header does not contain the row

      • getHeader

        protected Header getHeader()

        Returns the header section of this grid. The default header contains a single row, set as the default row.

        Returns:

        the header section

      • getFooterRow

        public FooterRow getFooterRow​(int index)

        Returns the footer row at the given index.

        Parameters:

        index - the index of the row, where the topmost row has index zero

        Returns:

        the footer row at the index

        Throws:

        IndexOutOfBoundsException - if rowIndex < 0 || rowIndex >= getFooterRowCount()

      • getFooterRowCount

        public int getFooterRowCount()

        Gets the number of rows in the footer section.

        Returns:

        the number of footer rows

      • setFooterVisible

        public void setFooterVisible​(boolean footerVisible)

        Sets the visibility of the Footer in this Grid.

        Parameters:

        footerVisible - true if visible; false if not

        Since:

        8.1.1

      • isFooterVisible

        public boolean isFooterVisible()

        Gets the visibility of the Footer in this Grid.

        Returns:

        true if visible; false if not

        Since:

        8.1.1

      • getFooter

        protected Footer getFooter()

        Returns the footer section of this grid.

        Returns:

        the footer section

      • addColumnReorderListener

        public Registration addColumnReorderListener​(ColumnReorderListener listener)

        Registers a new column reorder listener.

        Parameters:

        listener - the listener to register, not null

        Returns:

        a registration for the listener

      • addColumnResizeListener

        public Registration addColumnResizeListener​(ColumnResizeListener listener)

        Registers a new column resize listener.

        Parameters:

        listener - the listener to register, not null

        Returns:

        a registration for the listener

      • addColumnVisibilityChangeListener

        public Registration addColumnVisibilityChangeListener​(ColumnVisibilityChangeListener listener)

        Registers a new column visibility change listener.

        Parameters:

        listener - the listener to register, not null

        Returns:

        a registration for the listener

      • isColumnReorderingAllowed

        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

      • setColumns

        public void setColumns​(String... columnIds)

        Sets the columns and their order based on their column ids. Columns currently in this grid that are not present in the list of column ids are removed. This includes any column that has no id. Similarly, any new column in columns will be added to this grid. New columns can only be added for a Grid created using Grid(Class) or withPropertySet(PropertySet).

        Parameters:

        columnIds - the column ids to set

        See Also:

        Grid.Column.setId(String)

      • setColumns

        public void setColumns​(Collection<String> columnIds)

        Sets the columns and their order based on their column ids provided that collection supports preserving of the order. Columns currently in this grid that are not present in the collection of column ids are removed. This includes any column that has no id. Similarly, any new column in columns will be added to this grid. New columns can only be added for a Grid created using Grid(Class) or withPropertySet(PropertySet).

        Parameters:

        columnIds - the column ids to set

        See Also:

        Grid.Column.setId(String), setColumns(String...)

      • setColumnOrder

        public void setColumnOrder​(Grid.Column<T,​?>... columns)

        Sets a new column order for the grid. All columns which are not ordered here will remain in the order they were before as the last columns of grid.

        Parameters:

        columns - the columns in the order they should be

      • setColumnOrder

        public void setColumnOrder​(String... columnIds)

        Sets a new column order for the grid based on their column ids. All columns which are not ordered here will remain in the order they were before as the last columns of grid.

        Parameters:

        columnIds - the column ids in the order they should be

        See Also:

        Grid.Column.setId(String)

      • getSelectionModel

        public GridSelectionModel<T> getSelectionModel()

        Returns the selection model for this grid.

        Returns:

        the selection model, not null

      • getEditor

        public Editor<T> getEditor()

        Returns the Editor for this grid.

        Returns:

        the editor, not null

      • setSelectionModel

        protected void setSelectionModel​(GridSelectionModel<T> model)

        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 SingleSelectionModelImpl.

        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

        See Also:

        setSelectionMode(SelectionMode)

      • getSelectedItems

        public Set<T> getSelectedItems()

        This method is a shorthand that delegates to the currently set selection model.

        Returns:

        the items in the current selection, not null

        See Also:

        getSelectionModel(), GridSelectionModel

      • 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:

        getSelectionModel(), GridSelectionModel

      • 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:

        getSelectionModel(), GridSelectionModel

      • sort

        public void sort​(Grid.Column<T,​?> column)

        Sort this Grid in ascending order by a specified column.

        Parameters:

        column - a column to sort against

      • sort

        public void sort​(Grid.Column<T,​?> column,
                         SortDirection direction)

        Sort this Grid in user-specified direction by a column.

        Parameters:

        column - a column to sort against

        direction - a sort order value (ascending/descending)

      • sort

        public void sort​(String columnId)

        Sort this Grid in ascending order by a specified column defined by id.

        Parameters:

        columnId - the id of the column to sort against

        See Also:

        Grid.Column.setId(String)

      • sort

        public void sort​(String columnId,
                         SortDirection direction)

        Sort this Grid in a user-specified direction by a column defined by id.

        Parameters:

        columnId - the id of the column to sort against

        direction - a sort order value (ascending/descending)

        See Also:

        Grid.Column.setId(String)

      • clearSortOrder

        public void clearSortOrder()

        Clear the current sort order, and re-sort the grid.

      • getSortOrder

        public List<GridSortOrder<T>> getSortOrder()

        Get the current sort order list.

        Returns:

        a sort order list

      • scrollTo

        public void scrollTo​(int row)
                      throws IllegalArgumentException

        Scrolls to a certain item, using ScrollDestination.ANY.

        If the item has an open details row, its size will also be taken into account.

        Parameters:

        row - zero based index of the item to scroll to in the current view.

        Throws:

        IllegalArgumentException - if the provided row is outside the item range

      • scrollTo

        public void scrollTo​(int row,
                             ScrollDestination destination)

        Scrolls to a certain item, using user-specified scroll destination.

        If the item has an open details row, its size will also be taken into account.

        Parameters:

        row - zero based index of the item to scroll to in the current view.

        destination - value specifying desired position of scrolled-to row, not null

        Throws:

        IllegalArgumentException - if the provided row is outside the item range

      • scrollToStart

        public void scrollToStart()

        Scrolls to the beginning of the first data row.

      • scrollToEnd

        public void scrollToEnd()

        Scrolls to the end of the last data row.

      • scrollToColumn

        public void scrollToColumn​(String columnId)

        Scrolls to the given column, using ScrollDestination.ANY.

        Parameters:

        columnId - the id of the column, not null

        Throws:

        IllegalArgumentException - if there is no column with the given id

        Since:

        8.18

      • scrollToColumn

        public void scrollToColumn​(String columnId,
                                   ScrollDestination destination)

        Scrolls to the given column, using the given scroll destination.

        Parameters:

        columnId - the id of the column, not null

        destination - value specifying desired position of scrolled-to column, not null

        Throws:

        IllegalArgumentException - if there is no column with the given id

        Since:

        8.18

      • scrollToColumn

        public void scrollToColumn​(Grid.Column<T,​?> column)

        Scrolls to the given column, using ScrollDestination.ANY.

        Parameters:

        column - the column to scroll to, not null

        Since:

        8.18

      • scrollToColumn

        public void scrollToColumn​(Grid.Column<T,​?> column,
                                   ScrollDestination destination)

        Scrolls to the given column, using the given scroll destination.

        Parameters:

        column - the column to scroll to, not null

        destination - value specifying desired position of scrolled-to column, not null

        Since:

        8.18

      • getState

        protected GridState getState()

        Description copied from class: AbstractComponent

        Returns the shared state bean with information to be sent from the server to the client. Subclasses should override this method and set any relevant fields of the state returned by super.getState().

        Overrides:

        getState in class AbstractListing<T>

        Returns:

        updated component shared state

      • setColumnResizeMode

        public void setColumnResizeMode​(ColumnResizeMode mode)

        Sets the column resize mode to use. The default mode is ColumnResizeMode.ANIMATED.

        Parameters:

        mode - a ColumnResizeMode value

        Since:

        7.7.5

      • readItems

        protected void readItems​(org.jsoup.nodes.Element design,
                                 DesignContext context)

        Description copied from class: AbstractListing

        Reads the data source items from the design.

        Specified by:

        readItems in class AbstractListing<T>

        Parameters:

        design - The element to obtain the state from

        context - The DesignContext instance used for parsing the design

      • getDataProvider

        public DataProvider<T,​?> getDataProvider()

        Description copied from interface: HasItems

        Returns the source of data items used by this listing.

        Specified by:

        getDataProvider in interface HasItems<T>

        Returns:

        the data provider, not null

      • setDataProvider

        public void setDataProvider​(DataProvider<T,​?> dataProvider)

        Description copied from interface: HasDataProvider

        Sets the data provider for this listing. The data provider is queried for displayed items as needed.

        Specified by:

        setDataProvider in interface HasDataProvider<T>

        Parameters:

        dataProvider - the data provider, not null

      • setBeanType

        protected void setBeanType​(String beanTypeClassName)

        Sets the bean type to use for property mapping.

        This method is responsible also for setting or updating the property set so that it matches the given bean type.

        Protected mostly for Designer needs, typically should not be overridden or even called.

        Parameters:

        beanTypeClassName - the fully qualified class name of the bean type

        Since:

        8.0.3

      • setBeanType

        protected void setBeanType​(Class<T> beanType)

        Sets the bean type to use for property mapping.

        This method is responsible also for setting or updating the property set so that it matches the given bean type.

        Protected mostly for Designer needs, typically should not be overridden or even called.

        Parameters:

        beanType - the bean type class

        Since:

        8.0.3

      • setReadOnly

        public void setReadOnly​(boolean readOnly)

        Description copied from class: AbstractComponent

        Sets the read-only status in the state of this AbstractComponent. This method should be made public in Components that implement HasValue.

        Overrides:

        setReadOnly in class AbstractComponent

        Parameters:

        readOnly - a boolean value specifying whether the component is put read-only mode or not

      • readData

        protected void readData​(org.jsoup.nodes.Element body,
                                List<com.vaadin.ui.DeclarativeValueProvider<T>> providers)

        Reads the declarative representation of a grid's data from the given element and stores it in the given DeclarativeValueProviders. Each member in the list of value providers corresponds to a column in the grid.

        Parameters:

        body - the element to read data from

        providers - list of DeclarativeValueProviders to store the data of each column to

        Since:

        8.1

      • writeData

        protected void writeData​(org.jsoup.nodes.Element body,
                                 DesignContext designContext)

        Writes the data contained in this grid. Used when serializing a grid to its declarative representation, if DesignContext.shouldWriteData(Component) returns true for the grid that is being written.

        Parameters:

        body - the body element to write the declarative representation of data to

        designContext - the design context

        Since:

        8.1, 8.1

      • setColumnId

        protected void setColumnId​(String id,
                                   Grid.Column<T,​?> column)

        Sets a user-defined identifier for given column.

        Parameters:

        column - the column

        id - the user-defined identifier

        See Also:

        Grid.Column.setId(String)

      • getColumnByInternalId

        protected Grid.Column<T,​?> getColumnByInternalId​(String columnId)

        Returns a column identified by its internal id. This id should not be confused with the user-defined identifier.

        Parameters:

        columnId - the internal id of column

        Returns:

        column identified by internal id

      • getInternalIdForColumn

        protected String getInternalIdForColumn​(Grid.Column<T,​?> column)

        Returns the internal id for given column. This id should not be confused with the user-defined identifier.

        Parameters:

        column - the column

        Returns:

        internal id of given column

      • createSortingComparator

        protected SerializableComparator<T> createSortingComparator()

        Creates a comparator for grid to sort rows.

        Returns:

        the comparator based on column sorting information.