Interface DataGrid.Column<E>

All Superinterfaces:
Serializable
All Known Implementing Classes:
AbstractDataGrid.ColumnImpl
Enclosing interface:
DataGrid<E>

public static interface DataGrid.Column<E> extends Serializable
A column in the DataGrid.
  • Method Details

    • getId

      String getId()
      Returns:
      id of a column
    • getPropertyPath

      @Nullable MetaPropertyPath getPropertyPath()
      Returns:
      the instance of MetaPropertyPath representing a relative path to a property from certain MetaClass
    • getCaption

      @Nullable String getCaption()
      Returns:
      the caption of the header
    • setCaption

      @StudioProperty(type=LOCALIZED_STRING) void setCaption(String caption)
      Sets the caption of the header. This caption is also used as the hiding toggle caption, unless it is explicitly set via setCollapsingToggleCaption(String).
      Parameters:
      caption - the text to show in the caption
    • getCollapsingToggleCaption

      @Nullable String getCollapsingToggleCaption()
      Returns:
      the caption for the hiding toggle for this column
    • setCollapsingToggleCaption

      @StudioProperty(type=LOCALIZED_STRING) void setCollapsingToggleCaption(@Nullable String collapsingToggleCaption)
      Sets the caption of the hiding toggle for this column. Shown in the toggle for this column in the DataGrid's sidebar when the column is hidable.

      The default value is null, and in that case the column's header caption is used. NOTE: setting this to empty string might cause the hiding toggle to not render correctly.

      Parameters:
      collapsingToggleCaption - the text to show in the column hiding toggle
    • getWidth

      double getWidth()
      Returns:
      the width in pixels of the column
    • setWidth

      @StudioProperty(defaultValue="0") @PositiveOrZero void setWidth(double width)
      Sets the width (in pixels).

      This overrides any configuration set by any of setExpandRatio(int), setMinimumWidth(double) or setMaximumWidth(double).

      Parameters:
      width - the new pixel width of the column
    • isWidthAuto

      boolean isWidthAuto()
      Returns:
      whether the width is auto
    • setWidthAuto

      void setWidthAuto()
      Marks the column width as auto. An auto width means the DataGrid is free to resize the column based on the cell contents and available space in the grid.
    • getExpandRatio

      int getExpandRatio()
      Returns:
      the column's expand ratio
      See Also:
    • setExpandRatio

      @StudioProperty(name="expandRatio", defaultValue="0") void setExpandRatio(int expandRatio)
      Sets the ratio with which the column expands.

      By default, all columns expand equally (treated as if all of them had an expand ratio of 1). Once at least one column gets a defined expand ratio, the implicit expand ratio is removed, and only the defined expand ratios are taken into account.

      If a column has a defined width (setWidth(double)), it overrides this method's effects. Example: A DataGrid with three columns, with expand ratios 0, 1 and 2, respectively. The column with a ratio of 0 is exactly as wide as its contents requires. The column with a ratio of 1 is as wide as it needs, plus a third of any excess space, because we have 3 parts total, and this column reserves only one of those. The column with a ratio of 2, is as wide as it needs to be, plus two thirds of the excess width.

      Parameters:
      expandRatio - the expand ratio of this column. 0 to not have it expand at all. A negative number to clear the expand value.
      See Also:
    • clearExpandRatio

      void clearExpandRatio()
      Clears the expand ratio for this column.

      Equal to calling setExpandRatio(-1)

    • getMinimumWidth

      double getMinimumWidth()
      Returns:
      the minimum width for this column
      See Also:
    • setMinimumWidth

      @StudioProperty(name="minimumWidth", defaultValue="0") @PositiveOrZero void setMinimumWidth(double pixels)
      Sets the minimum width for this column.

      This defines the minimum guaranteed pixel width of the column when it is set to expand.

      Parameters:
      pixels - the new minimum pixel width of the column
      See Also:
    • getMaximumWidth

      double getMaximumWidth()
      Returns:
      the maximum width for this column
      See Also:
    • setMaximumWidth

      @StudioProperty(name="maximumWidth", defaultValue="0") @PositiveOrZero void setMaximumWidth(double pixels)
      Sets the maximum width for this column.

      This defines the maximum allowed pixel width of the column when it is set to expand.

      Parameters:
      pixels - the new maximum pixel width of the column
      See Also:
    • isVisible

      boolean isVisible()
      Returns:
      false if the column is currently hidden by security permissions, true otherwise
    • setVisible

      void setVisible(boolean visible)
      Hides or shows the column according to security permissions. Invisible column doesn't send any data to client side.
      Parameters:
      visible - false to hide the column, true to show
    • isCollapsed

      boolean isCollapsed()
      Returns:
      true if the column is currently hidden, false otherwise
    • setCollapsed

      @StudioProperty(defaultValue="false") void setCollapsed(boolean collapsed)
      Hides or shows the column. By default columns are visible before explicitly hiding them.
      Parameters:
      collapsed - true to hide the column, false to show
    • isCollapsible

      boolean isCollapsible()
      Returns whether this column can be hidden by the user. Default is true. Note: the column can be programmatically hidden using setCollapsed(boolean) regardless of the returned value.
      Returns:
      true if the user can hide the column, false if not
      See Also:
    • setCollapsible

      @StudioProperty(defaultValue="true") void setCollapsible(boolean collapsible)
      Sets whether this column can be hidden by the user. Hidable columns can be hidden and shown via the sidebar menu.
      Parameters:
      collapsible - true if the column may be hidden by the user via UI interaction
      See Also:
    • isSortable

      boolean isSortable()
      Returns whether the user can sort the grid by this column.
      Returns:
      true if the column is sortable by the user, false otherwise
    • setSortable

      @StudioProperty(defaultValue="true") void setSortable(boolean sortable)
      Sets whether this column is sortable by the user. The DataGrid can be sorted by a sortable column by clicking or tapping the column's default header.
      Parameters:
      sortable - true if the user should be able to sort the column, false otherwise
      See Also:
    • isResizable

      boolean isResizable()
      Returns whether this column can be resized by the user. Default is true. Note: the column can be programmatically resized using setWidth(double) and setWidthAuto() regardless of the returned value.
      Returns:
      true if this column is resizable, false otherwise
    • setResizable

      @StudioProperty(defaultValue="true") void setResizable(boolean resizable)
      Sets whether this column can be resized by the user.
      Parameters:
      resizable - true if this column should be resizable, false otherwise
    • getRenderer

      @Nullable DataGrid.Renderer getRenderer()
      Returns the renderer instance used by this column.
      Returns:
      the renderer
    • setRenderer

      void setRenderer(@Nullable DataGrid.Renderer renderer)
      Sets the renderer for this column. If given renderer is null, then the default renderer will be used.
      Parameters:
      renderer - the renderer to use
      See Also:
    • setRenderer

      void setRenderer(@Nullable DataGrid.Renderer renderer, @Nullable Function presentationProvider)
      Sets the renderer for this column. If given renderer is null, then the default renderer will be used.

      The presentation provider is a Function that takes the value of this column on a single row, and converts that to a value that the renderer accepts.

      The presentation provider takes precedence over formatter.

      Parameters:
      renderer - the renderer to use
      presentationProvider - the presentation provider to use
      See Also:
    • getPresentationProvider

      @Nullable Function getPresentationProvider()
      Returns:
      a function to get presentations from the value of this column
    • isEditable

      boolean isEditable()
      Returns whether the properties corresponding to this column should be editable when the item editor is active.
      Returns:
      true if this column is editable, false otherwise
      See Also:
    • setEditable

      @StudioProperty(defaultValue="true") void setEditable(boolean editable)
      Sets whether the properties corresponding to this column should be editable when the item editor is active. By default columns are editable.

      Values in non-editable columns are currently not displayed when the editor is active, but this will probably change in the future. They are not automatically assigned an editor field and, if one is manually assigned, it is not used. Columns that cannot (or should not) be edited even in principle should be set non-editable.

      Parameters:
      editable - true if this column should be editable, false otherwise
      See Also:
    • getEditFieldGenerator

      @Nullable Function<DataGrid.EditorFieldGenerationContext<E>,Field<?>> getEditFieldGenerator()
      Returns:
      field generator that generates a component for this column in DataGrid editor
    • setEditFieldGenerator

      void setEditFieldGenerator(@Nullable Function<DataGrid.EditorFieldGenerationContext<E>,Field<?>> generator)
      Parameters:
      generator - field generator that generates a component for this column in DataGrid editor.
    • getStyleProvider

      @Nullable Function<E,String> getStyleProvider()
      Returns:
      the style provider that is used for generating styles for cells
    • setStyleProvider

      void setStyleProvider(@Nullable Function<? super E,String> styleProvider)
      Sets the style provider for the DataGrid column.
      Parameters:
      styleProvider - a style provider to set
    • getDescriptionProvider

      @Nullable Function<E,String> getDescriptionProvider()
      Returns:
      the description provider that is used for generating descriptions for cells in this column
    • setDescriptionProvider

      void setDescriptionProvider(@Nullable Function<? super E,String> descriptionProvider)
      Sets the description provider that is used for generating descriptions for cells in this column.

      This method uses the ContentMode.PREFORMATTED content mode.

      Parameters:
      descriptionProvider - a description provider to set, or null to remove a previously set generator
    • setDescriptionProvider

      void setDescriptionProvider(Function<? super E,String> descriptionProvider, ContentMode contentMode)
      Sets the description provider that is used for generating descriptions for cells in this column.
      Parameters:
      descriptionProvider - a description provider to set, or null to remove a previously set generator
      contentMode - a content mode for row tooltips
    • getOwner

      @Nullable DataGrid<E> getOwner()
      Returns:
      The DataGrid this column belongs to
    • setOwner

      void setOwner(@Nullable DataGrid<E> owner)
      Parameters:
      owner - The DataGrid this column belongs to
    • setColumnGenerator

      default void setColumnGenerator(Function<DataGrid.ColumnGeneratorEvent<E>,?> columnGenerator)
      INTERNAL

      Intended to install declarative ColumnGenerator instance.

      Parameters:
      columnGenerator - column generator instance
    • getAggregation

      @Nullable AggregationInfo getAggregation()
      Returns:
      aggregation info
      See Also:
    • setAggregation

      void setAggregation(@Nullable AggregationInfo info)
      Sets an aggregation info in order to perform aggregation for this column.
      Parameters:
      info - aggregation info
      See Also:
    • getValueDescription

      @Nullable String getValueDescription()
      Returns:
      value description for aggregation row cells
      See Also:
    • setValueDescription

      void setValueDescription(@Nullable String valueDescription)
      Sets value description for aggregated row cells.
      Parameters:
      valueDescription - value description
      See Also: