Class EasyColumn<T,V>

java.lang.Object
com.flowingcode.vaadin.addons.easygrid.EasyColumn<T,V>
Type Parameters:
T - the grid bean type
V - the column value type
All Implemented Interfaces:
Serializable

public final class EasyColumn<T,V> extends Object implements Serializable
Wraps a Grid.Column and provides type-specific formatting for an EasyGridAddon-managed column.
See Also:
  • Method Details

    • as

      public <S> EasyColumn<T,S> as(Class<S> type)
      Returns this column cast to value type S, analogously to Class.asSubclass(java.lang.Class<U>). Succeeds when the column's actual value type is a subtype of S; throws otherwise.
      Type Parameters:
      S - the target value type
      Parameters:
      type - the target value type class
      Returns:
      this column cast to EasyColumn<T, S>
      Throws:
      ClassCastException - if the column's actual value type is not a subtype of type
    • setNullRepresentation

      public EasyColumn<T,V> setNullRepresentation(String nullRepresentation)
      Sets the string to display when the column value is null. Overrides any null representation inherited from the type or global configuration. Updates the underlying configuration and re-applies the renderer.
      Parameters:
      nullRepresentation - the string to show for null values
      Returns:
      this column, for fluent chaining
    • setFormatter

      public EasyColumn<T,V> setFormatter(SerializableFunction<V,String> formatter)
      Sets a custom formatter that converts the column value to a display string. Overrides any type-specific or formatter-based renderer inherited from the configuration chain.
      Parameters:
      formatter - a function mapping a column value to its display string
      Returns:
      this column, for fluent chaining
    • setRendererFactory

      public EasyColumn<T,V> setRendererFactory(RendererFactory<T,V> rendererFactory)
      Sets a custom renderer factory for this column. Overrides any type-specific or formatter-based renderer inherited from the configuration chain.
      Parameters:
      rendererFactory - a factory that creates a renderer from a value provider
      Returns:
      this column, for fluent chaining
    • setTextAlign

      public EasyColumn<T,V> setTextAlign(ColumnTextAlign textAlign)
      Sets the text alignment for this column's cells. Updates both the underlying Grid.Column and the ColumnConfiguration.
      Parameters:
      textAlign - the text alignment to apply
      Returns:
      this column, for fluent chaining
    • getColumn

      Grid.Column<T> getColumn()
      Returns the underlying Grid.Column.
      Returns:
      the underlying Grid.Column
    • setAutoWidth

      default EasyColumn<T,V> setAutoWidth(boolean autoWidth)
      Sets whether this column's width is automatically determined from its content.
      Parameters:
      autoWidth - true to enable auto-width, false to use a fixed width
      Returns:
      this column, for fluent chaining
    • setComparator

      default EasyColumn<T,V> setComparator(Comparator<T> comparator)
      Sets a comparator to use for in-memory sorting for this column.
      Parameters:
      comparator - the comparator to use
      Returns:
      this column, for fluent chaining
    • setComparator

      default <C extends Comparable<? super C>> EasyColumn<T,V> setComparator(ValueProvider<T,C> valueProvider)
      Sets a comparator to use for in-memory sorting for this column based on a value provider.
      Type Parameters:
      C - the comparable value type
      Parameters:
      valueProvider - a value provider that extracts the comparable sort key from a row item
      Returns:
      this column, for fluent chaining
    • setEditorComponent

      default EasyColumn<T,V> setEditorComponent(Component component)
      Sets the editor component for this column.
      Parameters:
      component - the editor component
      Returns:
      this column, for fluent chaining
    • setEditorComponent

      default EasyColumn<T,V> setEditorComponent(SerializableFunction<T,? extends Component> componentFunction)
      Sets a generator that provides the editor component for each row in this column.
      Parameters:
      componentFunction - a function that returns the editor component for a given row item
      Returns:
      this column, for fluent chaining
    • setFlexGrow

      default EasyColumn<T,V> setFlexGrow(int flexGrow)
      Sets the flex grow ratio for this column.
      Parameters:
      flexGrow - the flex grow ratio
      Returns:
      this column, for fluent chaining
    • setFooter

      default EasyColumn<T,V> setFooter(String footerText)
      Sets a text footer for this column.
      Parameters:
      footerText - the footer text
      Returns:
      this column, for fluent chaining
    • setFooter

      default EasyColumn<T,V> setFooter(Component footerComponent)
      Sets a component footer for this column.
      Parameters:
      footerComponent - the footer component
      Returns:
      this column, for fluent chaining
    • setFooterPartName

      default EasyColumn<T,V> setFooterPartName(String footerPartName)
      Sets the part name for the footer cell of this column.
      Parameters:
      footerPartName - the part name for the footer cell
      Returns:
      this column, for fluent chaining
    • setFrozen

      default EasyColumn<T,V> setFrozen(boolean frozen)
      Sets whether this column is frozen, locking it to the start of the grid.
      Parameters:
      frozen - true to freeze this column, false to unfreeze it
      Returns:
      this column, for fluent chaining
    • setFrozenToEnd

      default EasyColumn<T,V> setFrozenToEnd(boolean frozenToEnd)
      Sets whether this column is frozen to the end of the grid.
      Parameters:
      frozenToEnd - true to freeze this column to the end, false to unfreeze it
      Returns:
      this column, for fluent chaining
    • setHeader

      default EasyColumn<T,V> setHeader(String headerText)
      Sets a text header for this column.
      Parameters:
      headerText - the header text
      Returns:
      this column, for fluent chaining
    • setHeader

      default EasyColumn<T,V> setHeader(Component headerComponent)
      Sets a component header for this column.
      Parameters:
      headerComponent - the header component
      Returns:
      this column, for fluent chaining
    • setHeaderPartName

      default EasyColumn<T,V> setHeaderPartName(String headerPartName)
      Sets the part name for the header cell of this column.
      Parameters:
      headerPartName - the part name for the header cell
      Returns:
      this column, for fluent chaining
    • setKey

      default EasyColumn<T,V> setKey(String key)
      Sets the key for this column, used to retrieve it via Grid.getColumnByKey(String).
      Parameters:
      key - the column key
      Returns:
      this column, for fluent chaining
    • setPartNameGenerator

      default EasyColumn<T,V> setPartNameGenerator(SerializableFunction<T,String> partNameGenerator)
      Sets a generator that returns a part name for a given row item in this column.
      Parameters:
      partNameGenerator - a function that returns the part name for a given row item
      Returns:
      this column, for fluent chaining
    • setResizable

      default EasyColumn<T,V> setResizable(boolean resizable)
      Sets whether this column is user-resizable.
      Parameters:
      resizable - true to make this column resizable, false to prevent resizing
      Returns:
      this column, for fluent chaining
    • setRowHeader

      default EasyColumn<T,V> setRowHeader(boolean rowHeader)
      Sets whether this column represents a row header for accessibility purposes.
      Parameters:
      rowHeader - true to mark this column as a row header, false otherwise
      Returns:
      this column, for fluent chaining
    • setSortable

      default EasyColumn<T,V> setSortable(boolean sortable)
      Sets whether this column is user-sortable.
      Parameters:
      sortable - true to make this column sortable, false to disable sorting
      Returns:
      this column, for fluent chaining
    • setSortOrderProvider

      default EasyColumn<T,V> setSortOrderProvider(SortOrderProvider provider)
      Sets the sort order provider for this column.
      Parameters:
      provider - the sort order provider
      Returns:
      this column, for fluent chaining
    • setSortProperty

      default EasyColumn<T,V> setSortProperty(String... properties)
      Sets the backend properties used for sorting when this column is sorted.
      Parameters:
      properties - the backend property names used for sorting
      Returns:
      this column, for fluent chaining
    • setTooltipGenerator

      default EasyColumn<T,V> setTooltipGenerator(SerializableFunction<T,String> tooltipGenerator)
      Sets a generator that produces a tooltip for a given row item in this column.
      Parameters:
      tooltipGenerator - a function that returns the tooltip text for a given row item
      Returns:
      this column, for fluent chaining
    • setVisible

      default EasyColumn<T,V> setVisible(boolean visible)
      Sets whether this column is visible.
      Parameters:
      visible - true to show this column, false to hide it
      Returns:
      this column, for fluent chaining
    • setWidth

      default EasyColumn<T,V> setWidth(String width)
      Sets the width of this column as a CSS value.
      Parameters:
      width - the column width as a CSS value
      Returns:
      this column, for fluent chaining