Class DataGridColumn<E>

java.lang.Object
com.vaadin.flow.component.Component
io.jmix.groupgridflowui.kit.vaadin.grid.Grid.Column<E>
io.jmix.groupgridflowui.component.DataGridColumn<E>
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware
Direct Known Subclasses:
GroupDataGridColumn

public class DataGridColumn<E> extends Grid.Column<E> implements org.springframework.context.ApplicationContextAware
See Also:
  • Field Details

    • dataGridFilter

      protected GroupDataGridHeaderFilter dataGridFilter
    • applicationContext

      protected org.springframework.context.ApplicationContext applicationContext
    • partNameGenerator

      protected com.vaadin.flow.function.SerializableFunction<E,String> partNameGenerator
    • groupPartNameGenerator

      protected com.vaadin.flow.function.SerializableFunction<GroupInfo,String> groupPartNameGenerator
    • tooltipGenerator

      protected com.vaadin.flow.function.SerializableFunction<E,String> tooltipGenerator
    • groupTooltipGenerator

      protected com.vaadin.flow.function.SerializableFunction<GroupInfo,String> groupTooltipGenerator
    • storedHeaderText

      protected String storedHeaderText
    • storedHeaderComponent

      protected com.vaadin.flow.component.Component storedHeaderComponent
    • isGroupAllowed

      protected boolean isGroupAllowed
    • grid

      protected final Grid<?> grid
  • Constructor Details

    • DataGridColumn

      public DataGridColumn(GroupDataGrid<E> grid, String columnId, com.vaadin.flow.data.renderer.Renderer<E> renderer)
      Constructs a new DataGridColumn for use inside a GroupDataGrid.
      Parameters:
      grid - the grid this column is attached to
      columnId - unique identifier of this column
      renderer - the renderer to use in this column, must not be null
  • Method Details

    • getGrid

      public GroupDataGrid<E> getGrid()
      Gets the owner of this column.
      Returns:
      the grid which owns this column
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • setClassNameGenerator

      public Grid.Column<E> setClassNameGenerator(com.vaadin.flow.function.SerializableFunction<E,String> classNameGenerator)
      Description copied from class: Grid.Column
      Sets the function that is used for generating CSS class names for cells in this column. 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.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.

      Overrides:
      setClassNameGenerator in class Grid.Column<E>
      Parameters:
      classNameGenerator - the class name generator to set, not null
      Returns:
      this column
      See Also:
    • setFilterable

      public void setFilterable(boolean filterable)
      Sets the filtering for a column. If the filtering is enabled, a filter button will be added to the column header. The filtering is disabled by default.
      Parameters:
      filterable - whether to add a filter to the header
    • isFilterable

      public boolean isFilterable()
      Returns:
      true if the filter is added to the column header, false otherwise
    • isGroupAllowed

      public boolean isGroupAllowed()
      Returns:
      true if the column can be used in grouping
    • setGroupAllowed

      public void setGroupAllowed(boolean groupAllowed)
      Sets whether the column can be used in grouping.

      This method enables/disables grouping by this column in UI. The column can still be grouped programmatically using GroupDataGrid.groupByColumns(Grid.Column[]) and other methods.

      The default value is true.}

      Parameters:
      groupAllowed - whether the column can be used in grouping
    • setHeader

      public Grid.Column<E> setHeader(String labelText)
      Description copied from class: Grid.Column
      Sets a header text to the column.

      If there are no header rows when calling this method, the first header row will be created. If there are header rows, the header will be set on the first created header row and it will override any existing header.

      Overrides:
      setHeader in class Grid.Column<E>
      Parameters:
      labelText - the text to be shown at the column header
      Returns:
      this column, for method chaining
    • setHeader

      public Grid.Column<E> setHeader(@Nullable com.vaadin.flow.component.Component headerComponent)
      Description copied from class: Grid.Column
      Sets a header component to the column.

      If there are no header rows when calling this method, the first header row will be created. If there are header rows, the header will be set on the first created header row and it will override any existing header.

      Overrides:
      setHeader in class Grid.Column<E>
      Parameters:
      headerComponent - the component to be used in the header of the column
      Returns:
      this column, for method chaining
    • getPartNameGenerator

      @Nullable public com.vaadin.flow.function.SerializableFunction<E,String> getPartNameGenerator()
      Description copied from class: Grid.Column
      Gets the function that is used for generating CSS part names for cells in this column.
      Overrides:
      getPartNameGenerator in class Grid.Column<E>
      Returns:
      the part name generator
    • setPartNameGenerator

      public Grid.Column<E> setPartNameGenerator(@Nullable com.vaadin.flow.function.SerializableFunction<E,String> partNameGenerator)
      Description copied from class: Grid.Column
      Sets the function that is used for generating CSS part names for cells in this column. 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.setPartNameGenerator(SerializableFunction) is used together with this method, resulting part names from both methods will be effective.

      Overrides:
      setPartNameGenerator in class Grid.Column<E>
      Parameters:
      partNameGenerator - the part name generator to set, not null
      Returns:
      this column
      See Also:
    • getGroupPartNameGenerator

      @Nullable public com.vaadin.flow.function.SerializableFunction<GroupInfo,String> getGroupPartNameGenerator()
      Returns:
      group part name generator or null if not set
    • setGroupPartNameGenerator

      public DataGridColumn<E> setGroupPartNameGenerator(@Nullable com.vaadin.flow.function.SerializableFunction<GroupInfo,String> groupPartNameGenerator)
      Sets the part name generator for group item cell.
      Parameters:
      groupPartNameGenerator - the generator to set
      Returns:
      column instance
    • getTooltipGenerator

      @Nullable public com.vaadin.flow.function.SerializableFunction<E,String> getTooltipGenerator()
      Overrides:
      getTooltipGenerator in class Grid.Column<E>
      Returns:
      the tooltip generator for this column or null if not set
    • setTooltipGenerator

      public Grid.Column<E> setTooltipGenerator(@Nullable com.vaadin.flow.function.SerializableFunction<E,String> tooltipGenerator)
      Sets the tooltip generator for this column.
      Overrides:
      setTooltipGenerator in class Grid.Column<E>
      Parameters:
      tooltipGenerator - the tooltip generator to set
      Returns:
      column instance
    • getGroupTooltipGenerator

      @Nullable public com.vaadin.flow.function.SerializableFunction<GroupInfo,String> getGroupTooltipGenerator()
      Returns:
      the tooltip generator for group item cell or null if not set
    • setGroupTooltipGenerator

      public Grid.Column<E> setGroupTooltipGenerator(@Nullable com.vaadin.flow.function.SerializableFunction<GroupInfo,String> groupTooltipGenerator)
      Sets the tooltip generator for group item cell.
      Parameters:
      groupTooltipGenerator - the tooltip generator to set
      Returns:
      column instance
    • setVisible

      public void setVisible(boolean visible)

      Note that column related data is sent to the client side even if the column is invisible. Use Grid.removeColumn(Column) to remove column (or don't add the column all) and avoid sending extra data.

      See Also:
    • addColumnVisibilityChangedListener

      public com.vaadin.flow.shared.Registration addColumnVisibilityChangedListener(com.vaadin.flow.component.ComponentEventListener<GroupDataGridColumnVisibilityChangedEvent<E>> listener)
      Add listener for event of column visibility change
      Parameters:
      listener - the listener to add
      Returns:
      a registration handle to remove the listener
    • addDataGenerator

      protected com.vaadin.flow.shared.Registration addDataGenerator(com.vaadin.flow.data.provider.DataGenerator<E> dataGenerator)
      Overrides:
      addDataGenerator in class Grid.Column<E>
    • _getSortOrderProvider

      protected SortOrderProvider _getSortOrderProvider()
      Overrides:
      _getSortOrderProvider in class Grid.Column<E>
    • _getEditorComponentCallback

      @Nullable protected com.vaadin.flow.function.SerializableFunction<E,? extends com.vaadin.flow.component.Component> _getEditorComponentCallback()
      Overrides:
      _getEditorComponentCallback in class Grid.Column<E>
    • _getComparator

      protected com.vaadin.flow.function.SerializableComparator<E> _getComparator()
      Overrides:
      _getComparator in class Grid.Column<E>
    • getInternalId

      protected String getInternalId()
      Overrides:
      getInternalId in class Grid.Column<E>
    • onPartNameGenerator

      @Nullable protected String onPartNameGenerator(E item)
    • onTooltipGenerator

      @Nullable protected String onTooltipGenerator(E item)
    • groupDataGrid

      protected GroupDataGrid<E> groupDataGrid()
    • getStoredHeaderText

      @Nullable protected String getStoredHeaderText()
      Returns a header text that was directly set to the column. When a grid contains few header rows, the header component/text is removed and a value must be got from the cell of the header row. In some cases of group data grid the stored header component/text is required to be returned.
      Returns:
      the stored header text or null
    • getStoredHeaderComponent

      @Nullable protected com.vaadin.flow.component.Component getStoredHeaderComponent()
      Returns a header component that was directly set to the column. When a grid contains few header rows, the header component/text is removed and a value must be got from the cell of the header row. In some cases of group data grid the stored header component/text is required to be returned.
      Returns:
      the stored component or null
    • getHeaderText

      public String getHeaderText()
      Returns the header text of the column.
      Returns:
      the header text
    • setHeaderText

      protected void setHeaderText(String text)
    • getFooterText

      public String getFooterText()
      Returns the footer text of the column.
      Returns:
      the footer text
    • setFooterText

      protected void setFooterText(String text)
    • getHeaderComponent

      public com.vaadin.flow.component.Component getHeaderComponent()
      Returns the header component of the column.
      Returns:
      the header component
    • setHeaderComponent

      protected void setHeaderComponent(com.vaadin.flow.component.Component component)
    • getFooterComponent

      public com.vaadin.flow.component.Component getFooterComponent()
      Returns the footer component of the column.
      Returns:
      the footer component
    • setFooterComponent

      protected void setFooterComponent(com.vaadin.flow.component.Component component)
    • moveHeaderContent

      protected void moveHeaderContent(io.jmix.groupgridflowui.kit.vaadin.grid.AbstractColumn<?> otherColumn)
      Moves the current header content, either a text or a component, to a different column or column group. Also clears the content of this column.
      Parameters:
      otherColumn - the column or group to move the content to
    • moveFooterContent

      protected void moveFooterContent(io.jmix.groupgridflowui.kit.vaadin.grid.AbstractColumn<?> otherColumn)
      Moves the current footer content, either a text or a component, to a different column or column group. Also clears the content of this column.
      Parameters:
      otherColumn - the column or group to move the content to
    • updateSortingIndicators

      protected void updateSortingIndicators(boolean sortable)
      Updates this component to either have sorting indicators according to the sortable state of the underlying column, or removes the sorting indicators.
      Parameters:
      sortable - true to have sorting indicators if the column is sortable, false to not have sorting indicators
    • setSortingIndicators

      protected void setSortingIndicators(boolean sortingIndicators)
      Sets this component to show sorting indicators or not.
      Parameters:
      sortingIndicators - true to show sorting indicators, false to remove them
    • hasSortingIndicators

      protected boolean hasSortingIndicators()
    • getBottomChildColumns

      protected List<Grid.Column<?>> getBottomChildColumns()
      Gets recursively the child components of this component that are instances of Column.
      Returns:
      the Column children of this component
    • setResizable

      default Grid.Column<E> setResizable(boolean resizable)
      When set to true, the column is user-resizable. By default this is set to false.
      Parameters:
      resizable - whether to allow user resizing of this column
      Returns:
      this column, for method chaining
    • isResizable

      @Synchronize("resizable-changed") default boolean isResizable()
      Gets whether this column is user-resizable.
      Returns:
      whether this column is user-resizable
    • setFrozen

      default Grid.Column<E> setFrozen(boolean frozen)
      Sets this column's frozen state.

      Note: Columns are frozen in-place, freeze columns from left to right for a consistent outcome.

      Parameters:
      frozen - whether to freeze or unfreeze this column
      Returns:
      this column, for method chaining
    • isFrozen

      @Synchronize("frozen-changed") default boolean isFrozen()
      Gets the this column's frozen state.
      Returns:
      whether this column is frozen
    • setFrozenToEnd

      default Grid.Column<E> setFrozenToEnd(boolean frozenToEnd)
      Sets this column's frozen state.

      Note: Columns are frozen in-place, freeze columns from right to left for a consistent outcome.

      Parameters:
      frozenToEnd - whether to freeze or unfreeze this column
      Returns:
      this column, for method chaining
      Since:
      23.1
    • isFrozenToEnd

      @Synchronize("frozen-to-end-changed") default boolean isFrozenToEnd()
      Gets the this column's frozen state.
      Returns:
      whether this column is frozen to end
      Since:
      23.1
    • setTextAlign

      default Grid.Column<E> setTextAlign(ColumnTextAlign textAlign)
      Sets the column text align.
      Parameters:
      textAlign - the text alignment of the column. Setting it to null resets the alignment to the default value ColumnTextAlign.START.
      Returns:
      this column, for method chaining
    • getTextAlign

      @Synchronize("text-align-changed") default ColumnTextAlign getTextAlign()
      Gets the column text align. The default is ColumnTextAlign.START.
      Returns:
      the column text align, not null
    • setHeaderPartName

      default Grid.Column<E> setHeaderPartName(String headerPartName)
      Sets a custom part name for the header cell.
      Parameters:
      headerPartName - the part name to set
      Returns:
      this column, for method chaining
    • getHeaderPartName

      default String getHeaderPartName()
      Gets the custom part name of the header cell.
      Returns:
      the part name
    • setFooterPartName

      default Grid.Column<E> setFooterPartName(String footerPartName)
      Sets a custom part name for the footer cell.
      Parameters:
      footerPartName - the part name to set
      Returns:
      this column, for method chaining
    • getFooterPartName

      default String getFooterPartName()
      Gets the custom part name of the footer cell.
      Returns:
      the part name