Interface Table<E>

Type Parameters:
E - row item type
All Superinterfaces:
ActionsHolder, Component, Component.BelongToFrame, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, HasButtonsPanel, HasContextHelp, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasMinSize, HasPagination, HasSubParts, HasTablePresentations, ListComponent<E>, LookupComponent<E>
All Known Subinterfaces:
GroupTable<E>, TreeTable<E>
All Known Implementing Classes:
AbstractTable, GroupTableImpl, TableImpl, TreeTableImpl

@StudioComponent(caption="Table", category="Components", xmlElement="table", icon="io/jmix/ui/icon/component/table.svg", canvasBehaviour=TABLE, documentationURL="https://docs.jmix.io/jmix/%VERSION%/ui/vcl/components/table.html") public interface Table<E> extends ListComponent<E>, Component.Editable, HasButtonsPanel, HasTablePresentations, Component.HasCaption, HasContextHelp, Component.HasIcon, LookupComponent<E>, Component.Focusable, HasSubParts, HasHtmlCaption, HasHtmlDescription, HasHtmlSanitizer, HasPagination, HasMinSize
Table UI component bound to entity type.
  • Field Details

  • Method Details

    • of

      static <T> org.springframework.core.ParameterizedTypeReference<Table<T>> of(Class<T> itemClass)
    • getColumns

      @StudioElementsGroup(xmlElement="columns", caption="Columns", icon="io/jmix/ui/icon/element/columns.svg") List<Table.Column<E>> getColumns()
      Returns a copy of currently configured columns in their current visual order in this Table.
      Returns:
      unmodifiable copy of current columns
      See Also:
    • getColumn

      @Nullable Table.Column<E> getColumn(String id)
      Returns a column by id.
      Parameters:
      id - the column id
      Returns:
      the column or null if not found
    • addColumn

      void addColumn(Table.Column<E> column)
      Adds the given column to Table.

      Note that column id should be an instance of MetaPropertyPath.

      Parameters:
      column - the column to add
      See Also:
    • addColumn

      void addColumn(Table.Column<E> column, int index)
      Adds the given column at the specified index to Table.

      Note that column id should be an instance of MetaPropertyPath.

      Parameters:
      column - the column to add
      index - index of a new column
      See Also:
    • addColumn

      Table.Column<E> addColumn(Object id)
      Creates new column with given Id, then adds this column to Table.
      Parameters:
      id - the column id or the instance of MetaPropertyPath representing a relative path to a property from certain MetaClass
      Returns:
      the newly created column
      See Also:
    • addColumn

      Table.Column<E> addColumn(Object id, int index)
      Creates new column with given Id at the specified index, then adds this column to Table.
      Parameters:
      id - the column id or the instance of MetaPropertyPath representing a relative path to a property from certain MetaClass
      index - index of a new column
      Returns:
      the newly created column
      See Also:
    • removeColumn

      void removeColumn(Table.Column<E> column)
      Removes the given column from Table or do nothing if column is null.
      Parameters:
      column - the column to remove
    • getAggregationResults

      Map<Object,Object> getAggregationResults()
      Returns a map with aggregation results, where keys are table column ids and values are aggregation values.
      Returns:
      map with aggregation results
    • setItems

      void setItems(@Nullable TableItems<E> tableItems)
      Sets an instance of TableItems as the Table data source.
      Parameters:
      tableItems - the Table data source
    • getItems

      @Nullable TableItems<E> getItems()
      Specified by:
      getItems in interface ListComponent<E>
      Returns:
      the Table data source
    • setRequired

      void setRequired(Table.Column<E> column, boolean required, String message)
      Sets whether the component inside a column must contain a non-null value.
      Parameters:
      column - a column
      required - required
      message - required message
    • setTextSelectionEnabled

      @StudioProperty(defaultValue="false") void setTextSelectionEnabled(boolean textSelectionEnabled)
      Sets whether text selection in Table cells is enabled.
      Parameters:
      textSelectionEnabled - whether text selection in Table cells is enabled
    • isTextSelectionEnabled

      boolean isTextSelectionEnabled()
      Returns:
      whether text selection in Table cells is enabled
    • setItemClickAction

      void setItemClickAction(Action action)
      Assign action to be executed on double click inside a table row.

      If such action is not set, the table responds to double click by trying to find and execute the following actions:

      • action, assigned to Enter key press by setting its shortcut property
      • action named "edit"
      • action named "view"
      If one of these actions is found and it is enabled, it is executed.
    • getItemClickAction

      @Nullable Action getItemClickAction()
      Returns:
      an action that is performed when the user double-clicks inside a table row
      See Also:
    • setEnterPressAction

      void setEnterPressAction(Action action)
      Assign action to be executed on Enter key press.

      If such action is not set, the table responds to pressing Enter by trying to find and execute the following actions:

      • action, assigned by setItemClickAction(Action)
      • action, assigned to Enter key press by setting its shortcut property
      • action named "edit"
      • action named "view"
      If one of these actions is found and it is enabled, it is executed.
    • getEnterPressAction

      @Nullable Action getEnterPressAction()
      Returns:
      an action to be executed on Enter key press, assigned by setEnterPressAction(Action)
    • getNotCollapsedColumns

      List<Table.Column> getNotCollapsedColumns()
      Returns:
      a list of visible columns
    • setSortable

      @StudioProperty(defaultValue="true") void setSortable(boolean sortable)
      Defines if sortable attribute can be changed for individual column or not. Default value is true.
      Parameters:
      sortable - true if individual column sortable attribute can be set to true, false otherwise
    • isSortable

      boolean isSortable()
      Returns:
      true if individual column sortable attribute can be set to true, false otherwise
    • setAggregatable

      @StudioProperty(defaultValue="false") void setAggregatable(boolean aggregatable)
      Sets whether aggregation is enabled. Default value is false.
      Parameters:
      aggregatable - whether aggregation is enabled.
    • isAggregatable

      boolean isAggregatable()
      Returns:
      true if the Table is aggregatable
    • setShowTotalAggregation

      @StudioProperty(defaultValue="true") void setShowTotalAggregation(boolean showAggregation)
      Shows in which aggregation the changes occurred: in the total or group.
      Parameters:
      showAggregation - true if the aggregation column should show changes in total aggregation, false if in the group aggregation
    • isShowTotalAggregation

      boolean isShowTotalAggregation()
      Returns:
      true if the aggregation column should show changes in total aggregation, false if in the group aggregation
    • setColumnReorderingAllowed

      @StudioProperty(name="reorderingAllowed", defaultValue="true") void setColumnReorderingAllowed(boolean columnReorderingAllowed)
      Sets whether or not column reordering is allowed. Default value is true.
      Parameters:
      columnReorderingAllowed - specifies whether column reordering is allowed
    • getColumnReorderingAllowed

      boolean getColumnReorderingAllowed()
      Returns whether column reordering is allowed. Default value is true.
      Returns:
      true if reordering is allowed
    • addColumnReorderListener

      Subscription addColumnReorderListener(Consumer<Table.ColumnReorderEvent<E>> listener)
      Registers a new column reorder listener.
      Parameters:
      listener - the listener to add
      Returns:
      a registration object for removing an event listener
    • setColumnControlVisible

      @StudioProperty(defaultValue="true") void setColumnControlVisible(boolean columnControlVisible)
      Sets whether user can hide columns using the columnControlButton dropdown on the right side of the table header.
      Parameters:
      columnControlVisible - whether user can hide columns using the columnControlButton dropdown on the right side of the table header
    • getColumnControlVisible

      boolean getColumnControlVisible()
      Returns:
      whether user can hide columns using the columnControlButton dropdown on the right side of the table header
    • requestFocus

      void requestFocus(E entity, String columnId)
      Sets focus on inner field of editable/generated column.
      Parameters:
      entity - entity
      columnId - column id
    • scrollTo

      void scrollTo(E entity)
      Scrolls table to specified row.
      Parameters:
      entity - entity
    • sort

      void sort(String columnId, Table.SortDirection direction)
      Sorts the Table data for passed column id in the chosen sort direction.
      Parameters:
      columnId - id of the column to sort
      direction - sort direction
    • getSortInfo

      @Nullable Table.SortInfo getSortInfo()
      Returns:
      current sort information or null if no column is sorted
    • selectAll

      void selectAll()
      Marks all the items in the current data source as selected.
    • isMultiLineCells

      boolean isMultiLineCells()
      Returns:
      whether multi-line display is enabled for cells containing several lines of text
    • setMultiLineCells

      @StudioProperty(defaultValue="false") void setMultiLineCells(boolean multiLineCells)
      Sets whether multi-line display is enabled for cells containing several lines of text. The default value is false.
      Parameters:
      multiLineCells - whether multi-line display is enabled for cells containing several lines of text
    • isContextMenuEnabled

      boolean isContextMenuEnabled()
      Returns:
      whether context menu is enabled
    • setContextMenuEnabled

      @StudioProperty(defaultValue="true") void setContextMenuEnabled(boolean contextMenuEnabled)
      Sets whether context menu is enabled.
      Parameters:
      contextMenuEnabled - whether context menu is enabled
    • setRowHeaderWidth

      void setRowHeaderWidth(int width)
      Sets the width of row header column. Row header shows icons if Icon Provider is specified.
      Parameters:
      width - width of row header column in px
    • getRowHeaderWidth

      int getRowHeaderWidth()
      Returns:
      width of row header column in px
    • setMultiSelect

      @StudioProperty(name="multiselect", defaultValue="false") void setMultiSelect(boolean multiselect)
      Sets whether multiple selection mode is enabled.
      Parameters:
      multiselect - whether multiple selection mode is enabled
    • repaint

      void repaint()
      Repaints UI representation of the table (columns, generated columns) without refreshing the table data.
    • getSubPart

      @Nullable default Object getSubPart(String name)
      Specified by:
      getSubPart in interface ActionsHolder
      Specified by:
      getSubPart in interface HasSubParts
    • setEmptyStateMessage

      @StudioProperty(name="emptyStateMessage", type=LOCALIZED_STRING) void setEmptyStateMessage(@Nullable String message)
      Sets a message to the middle of Table body that should be appeared when Table is empty.
      Parameters:
      message - message that appears when Table is empty
    • getEmptyStateMessage

      @Nullable String getEmptyStateMessage()
      Returns:
      message that should be appeared when Table is empty
    • setEmptyStateLinkMessage

      @StudioProperty(name="emptyStateLinkMessage", type=LOCALIZED_STRING) void setEmptyStateLinkMessage(@Nullable String linkMessage)
      Sets a link message to the middle of Table body that should be appeared when Table is empty.
      Parameters:
      linkMessage - message that appears when Table is empty
      See Also:
    • getEmptyStateLinkMessage

      @Nullable String getEmptyStateLinkMessage()
      Returns:
      link message that should be appeared when Table is empty
    • setEmptyStateLinkClickHandler

      void setEmptyStateLinkClickHandler(@Nullable Consumer<Table.EmptyStateClickEvent<E>> handler)
      Sets click handler for link message. Link message can be shown when Table is empty.
      Parameters:
      handler - handler to set
      See Also:
    • getEmptyStateLinkClickHandler

      @Nullable Consumer<Table.EmptyStateClickEvent<E>> getEmptyStateLinkClickHandler()
      Returns:
      click handler for link message
    • getMinHeight

      @Nullable Float getMinHeight()
      Specified by:
      getMinHeight in interface HasMinSize
      Returns:
      min-height CSS property value of the Table (not a composition) or null if not set
    • getMinHeightSizeUnit

      @Nullable SizeUnit getMinHeightSizeUnit()
      Specified by:
      getMinHeightSizeUnit in interface HasMinSize
      Returns:
      unit size of min-height CSS property value of the Table (not a composition)
    • setMinHeight

      void setMinHeight(@Nullable String minHeight)
      Sets minHeight CSS property value to the Table (not a composition). To set CSS properties to the composition use css attribute in the XML descriptor or HtmlAttributes.applyCss(Component, String).
      Specified by:
      setMinHeight in interface HasMinSize
      Parameters:
      minHeight - property value
    • getMinWidth

      @Nullable Float getMinWidth()
      Specified by:
      getMinWidth in interface HasMinSize
      Returns:
      min-width CSS property value of the Table (not a composition) or null if not set
    • getMinWidthSizeUnit

      @Nullable SizeUnit getMinWidthSizeUnit()
      Specified by:
      getMinWidthSizeUnit in interface HasMinSize
      Returns:
      unit size of min-width CSS property value of the Table (not a composition)
    • setMinWidth

      void setMinWidth(@Nullable String minWidth)
      Sets minWidth CSS property value to the Table (not a composition). To set CSS properties to the composition use css attribute in the XML descriptor or HtmlAttributes.applyCss(Component, String).
      Specified by:
      setMinWidth in interface HasMinSize
      Parameters:
      minWidth - property value
    • addColumnCollapseListener

      Subscription addColumnCollapseListener(Consumer<Table.ColumnCollapseEvent<E>> listener)
      Adds a listener for column collapse events.
      Parameters:
      listener - a listener to add
      Returns:
      a Subscription object
    • setRowHeaderMode

      @StudioProperty(type=ENUMERATION, defaultValue="NONE", options={"NONE","ICON"}) void setRowHeaderMode(Table.RowHeaderMode mode)
      Sets the row header mode.
      Parameters:
      mode - row header mode
    • setAggregationStyle

      @StudioProperty(type=ENUMERATION, defaultValue="TOP", options={"TOP","BOTTOM"}) void setAggregationStyle(Table.AggregationStyle aggregationStyle)
      Sets the location of the aggregation row.
      Parameters:
      aggregationStyle - the location of the aggregation row
    • getAggregationStyle

      Table.AggregationStyle getAggregationStyle()
      Returns:
      the location of the aggregation row
    • setStyleProvider

      void setStyleProvider(@Nullable Table.StyleProvider<? super E> styleProvider)
      Sets the cell style provider for the table.
      All style providers added before this call will be removed.
      Parameters:
      styleProvider - a style provider to set
    • addStyleProvider

      void addStyleProvider(Table.StyleProvider<? super E> styleProvider)
      Add style provider for the table.
      Table can use several providers to obtain many style names for cells and rows.
      Parameters:
      styleProvider - a style provider to add
    • removeStyleProvider

      void removeStyleProvider(Table.StyleProvider<? super E> styleProvider)
      Removes style provider for the table.
      Parameters:
      styleProvider - a style provider to remove
    • setIconProvider

      void setIconProvider(@Nullable Function<? super E,String> iconProvider)
      Sets the row icon provider for the Table.
      Parameters:
      iconProvider - an icon provider to set
      See Also:
    • setItemDescriptionProvider

      void setItemDescriptionProvider(@Nullable BiFunction<? super E,String,String> provider)
      Sets the item description provider that is used for generating tooltip descriptions for items.

      All unhandled exceptions from ItemDescriptionProvider in Web components by default are logged with ERROR level and not shown to users.

      Parameters:
      provider - the item description provider to use or null to remove a previously set provider if any
    • getItemDescriptionProvider

      @Nullable BiFunction<? super E,String,String> getItemDescriptionProvider()
      Gets the item description provider.
      Returns:
      the item description provider
    • getInstanceContainer

      InstanceContainer<E> getInstanceContainer(E item)
      This method returns the InstanceContainer which contains the provided item. It can be used in data-aware components, created in generated columns.
      Do not save to final variables, just get it from table when you need.
      
       carsTable.addGeneratedColumn("name", car -> {
           TextField<String> textField = uiComponents.create(TextField.NAME);
           textField.setValueSource(new ContainerValueSource<>(carsTable.getInstanceContainer(car),"name"));
           textField.setValue(car.getName());
           return textField;
       });
       
      Parameters:
      item - entity item
      Returns:
      InstanceContainer containing the item
    • addGeneratedColumn

      void addGeneratedColumn(String columnId, Table.ColumnGenerator<? super E> generator)
      Adds a generated column to the table.
      Parameters:
      columnId - column identifier as defined in XML descriptor. May or may not correspond to an entity property.
      generator - column generator instance
    • addGeneratedColumn

      void addGeneratedColumn(String columnId, int index, Table.ColumnGenerator<? super E> generator)
      Adds a generated column at the specified index to Table.
      Parameters:
      columnId - column identifier as defined in XML descriptor. May correspond to an entity property
      index - index of a new column
      generator - column generator instance
    • addGeneratedColumn

      void addGeneratedColumn(String columnId, Table.ColumnGenerator<? super E> generator, Class<? extends Component> componentClass)
      Adds a generated column to the table.
      This method useful for desktop UI. Table can make additional look, feel and performance tweaks if it knows the class of components that will be generated.
      Parameters:
      columnId - column identifier as defined in XML descriptor. May or may not correspond to an entity property.
      generator - column generator instance
      componentClass - class of components that generator will provide
    • removeGeneratedColumn

      void removeGeneratedColumn(String columnId)
      Removes generated column from the Table by column id.
      Parameters:
      columnId - the column id
    • addPrintable

      @Deprecated void addPrintable(String columnId, Table.Printable<? super E,?> printable)
      Deprecated.
      Use export action APIs instead.
      Adds Table.Printable representation for column.
      Explicitly added Printable will be used instead of inherited from generated column.
      Parameters:
      columnId - column id
      printable - printable representation
    • removePrintable

      @Deprecated void removePrintable(String columnId)
      Deprecated.
      Use export action APIs instead.
      Removes Table.Printable representation of column.
      Unable to remove Printable representation inherited from generated column.
      Parameters:
      columnId - column id
    • getPrintable

      @Nullable @Deprecated Table.Printable getPrintable(Table.Column column)
      Deprecated.
      Use export action APIs instead.
      Gets Table.Printable representation for column.
      Parameters:
      column - table column
      Returns:
      printable
    • getPrintable

      @Nullable @Deprecated Table.Printable getPrintable(String columnId)
      Deprecated.
      Use export action APIs instead.
      Gets Table.Printable representation for column.
      Parameters:
      columnId - column id
      Returns:
      printable
    • setAggregationDistributionProvider

      void setAggregationDistributionProvider(@Nullable Table.AggregationDistributionProvider<E> distributionProvider)
      Sets aggregation distribution provider to handle distribution of data on rows. Supports only TOP aggregation style.
      Parameters:
      distributionProvider - distribution provider
    • getAggregationDistributionProvider

      @Nullable Table.AggregationDistributionProvider<E> getAggregationDistributionProvider()
      Returns:
      aggregation distribution provider
    • showCustomPopup

      void showCustomPopup(Component popupComponent)
      Shows popup inside of Table, relative to last cell click event.
      Call this method from Table.Column.ClickEvent implementation.
      Parameters:
      popupComponent - popup content
    • showCustomPopupActions

      void showCustomPopupActions(List<Action> actions)
      Shows autocloseable popup view with actions, relative to last cell click event.
      Call this method from Table.Column.ClickEvent implementation.
      Autocloseable means that after any click on action popup will be closed.
      Parameters:
      actions - actions
    • setColumnHeaderVisible

      @StudioProperty(defaultValue="true") void setColumnHeaderVisible(boolean columnHeaderVisible)
      Sets whether table header is displayed.
      Parameters:
      columnHeaderVisible - whether table header is displayed
    • isColumnHeaderVisible

      boolean isColumnHeaderVisible()
      Returns:
      whether table header is displayed
    • setShowSelection

      @StudioProperty(defaultValue="true") void setShowSelection(boolean showSelection)
      Sets whether a current row is highlighted.
      Parameters:
      showSelection - whether a current row is highlighted
    • isShowSelection

      boolean isShowSelection()
      Returns:
      whether a current row is highlighted
    • addSelectionListener

      Subscription addSelectionListener(Consumer<Table.SelectionEvent<E>> listener)
      Registers a new selection listener
      Parameters:
      listener - the listener to register