E
- row item type@StudioComponent(caption="Table", category="Components", xmlElement="table", icon="io/jmix/ui/icon/component/table.svg", canvasBehaviour=TABLE, documentationURL="https://docs.jmix.io/jmix/%VERSION%/backoffice-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
Modifier and Type | Interface and Description |
---|---|
static class |
Table.AggregationDistributionContext<E>
Object that contains information about aggregation distribution.
|
static interface |
Table.AggregationDistributionProvider<E>
Allows to handle a group or total aggregation value changes.
|
static class |
Table.AggregationStyle
The location of the aggregation row.
|
static interface |
Table.Column<E>
Table column.
|
static class |
Table.ColumnAlignment
Column alignment.
|
static class |
Table.ColumnCollapseEvent<E>
Event sent every time column collapse state changes.
|
static interface |
Table.ColumnGenerator<E>
Allows rendering of an arbitrary
Component inside a table cell. |
static class |
Table.ColumnReorderEvent<E>
An event that is fired when a columns are reordered by the user.
|
static class |
Table.EmptyStateClickEvent<E>
Describes empty state link click event.
|
static class |
Table.PlainTextCell
Special component for generated columns which will be rendered as simple text cell.
|
static interface |
Table.Printable<E,P>
Allows set Printable representation for column in Excel export.
|
static interface |
Table.PrintableColumnGenerator<E,P>
Column generator, which supports print to Excel.
|
static class |
Table.RowHeaderMode
Row header mode.
|
static class |
Table.SelectionEvent<E>
Event sent when the selection changes.
|
static class |
Table.SortDirection
Describes sorting direction.
|
static class |
Table.SortInfo
Object that contains information about column sorting.
|
static interface |
Table.StyleProvider<E>
Allows to define different styles for table cells.
|
Component.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.Wrapper
HasContextHelp.ContextHelpIconClickEvent
LookupComponent.LookupSelectionChangeEvent<T>, LookupComponent.LookupSelectionChangeNotifier<T>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
NAME |
AUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE
Modifier and Type | Method and Description |
---|---|
Table.Column<E> |
addColumn(java.lang.Object id)
Creates new column with given Id, then adds this column to Table.
|
Table.Column<E> |
addColumn(java.lang.Object id,
int index)
Creates new column with given Id at the specified index, then adds this column to Table.
|
void |
addColumn(Table.Column<E> column)
Adds the given column to Table.
|
void |
addColumn(Table.Column<E> column,
int index)
Adds the given column at the specified index to Table.
|
io.jmix.core.common.event.Subscription |
addColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent<E>> listener)
Adds a listener for column collapse events.
|
io.jmix.core.common.event.Subscription |
addColumnReorderListener(java.util.function.Consumer<Table.ColumnReorderEvent<E>> listener)
Registers a new column reorder listener.
|
void |
addGeneratedColumn(java.lang.String columnId,
int index,
Table.ColumnGenerator<? super E> generator)
Adds a generated column at the specified index to Table.
|
void |
addGeneratedColumn(java.lang.String columnId,
Table.ColumnGenerator<? super E> generator)
Adds a generated column to the table.
|
void |
addGeneratedColumn(java.lang.String columnId,
Table.ColumnGenerator<? super E> generator,
java.lang.Class<? extends Component> componentClass)
Adds a generated column to the table.
|
void |
addPrintable(java.lang.String columnId,
Table.Printable<? super E,?> printable)
Adds
Table.Printable representation for column. |
io.jmix.core.common.event.Subscription |
addSelectionListener(java.util.function.Consumer<Table.SelectionEvent<E>> listener)
Registers a new selection listener
|
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. |
Table.AggregationDistributionProvider<E> |
getAggregationDistributionProvider() |
java.util.Map<java.lang.Object,java.lang.Object> |
getAggregationResults()
Returns a map with aggregation results, where keys are table column ids and values are aggregation values.
|
Table.AggregationStyle |
getAggregationStyle() |
Table.Column<E> |
getColumn(java.lang.String id)
Returns a column by id.
|
boolean |
getColumnControlVisible() |
boolean |
getColumnReorderingAllowed()
Returns whether column reordering is allowed.
|
java.util.List<Table.Column<E>> |
getColumns()
Returns a copy of currently configured columns in their current visual
order in this Table.
|
java.util.function.Consumer<Table.EmptyStateClickEvent<E>> |
getEmptyStateLinkClickHandler() |
java.lang.String |
getEmptyStateLinkMessage() |
java.lang.String |
getEmptyStateMessage() |
Action |
getEnterPressAction() |
InstanceContainer<E> |
getInstanceContainer(E item)
This method returns the InstanceContainer which contains the provided item.
|
Action |
getItemClickAction() |
java.util.function.BiFunction<? super E,java.lang.String,java.lang.String> |
getItemDescriptionProvider()
Gets the item description provider.
|
TableItems<E> |
getItems() |
java.util.List<Table.Column> |
getNotCollapsedColumns() |
Table.Printable |
getPrintable(java.lang.String columnId)
Gets
Table.Printable representation for column. |
Table.Printable |
getPrintable(Table.Column column)
Gets
Table.Printable representation for column. |
int |
getRowHeaderWidth() |
Table.SortInfo |
getSortInfo() |
default java.lang.Object |
getSubPart(java.lang.String name) |
boolean |
isAggregatable() |
boolean |
isColumnHeaderVisible() |
boolean |
isContextMenuEnabled() |
boolean |
isMultiLineCells() |
boolean |
isShowSelection() |
boolean |
isShowTotalAggregation() |
boolean |
isSortable() |
boolean |
isTextSelectionEnabled() |
static <T> org.springframework.core.ParameterizedTypeReference<Table<T>> |
of(java.lang.Class<T> itemClass) |
void |
removeColumn(Table.Column<E> column)
Removes the given column from Table or do nothing if column is
null . |
void |
removeGeneratedColumn(java.lang.String columnId)
Removes generated column from the Table by column id.
|
void |
removePrintable(java.lang.String columnId)
Removes
Table.Printable representation of column. |
void |
removeStyleProvider(Table.StyleProvider<? super E> styleProvider)
Removes style provider for the table.
|
void |
repaint()
Repaints UI representation of the table (columns, generated columns) without refreshing the table data.
|
void |
requestFocus(E entity,
java.lang.String columnId)
Sets focus on inner field of editable/generated column.
|
void |
scrollTo(E entity)
Scrolls table to specified row.
|
void |
selectAll()
Marks all the items in the current data source as selected.
|
void |
setAggregatable(boolean aggregatable)
Sets whether aggregation is enabled.
|
void |
setAggregationDistributionProvider(Table.AggregationDistributionProvider<E> distributionProvider)
Sets aggregation distribution provider to handle distribution of data on rows.
|
void |
setAggregationStyle(Table.AggregationStyle aggregationStyle)
Sets the location of the aggregation row.
|
void |
setColumnControlVisible(boolean columnControlVisible)
Sets whether user can hide columns using the columnControlButton dropdown on
the right side of the table header.
|
void |
setColumnHeaderVisible(boolean columnHeaderVisible)
Sets whether table header is displayed.
|
void |
setColumnReorderingAllowed(boolean columnReorderingAllowed)
Sets whether or not column reordering is allowed.
|
void |
setContextMenuEnabled(boolean contextMenuEnabled)
Sets whether context menu is enabled.
|
void |
setEmptyStateLinkClickHandler(java.util.function.Consumer<Table.EmptyStateClickEvent<E>> handler)
Sets click handler for link message.
|
void |
setEmptyStateLinkMessage(java.lang.String linkMessage)
Sets a link message to the middle of Table body that should be appeared when Table is empty.
|
void |
setEmptyStateMessage(java.lang.String message)
Sets a message to the middle of Table body that should be appeared when Table is empty.
|
void |
setEnterPressAction(Action action)
Assign action to be executed on Enter key press.
|
void |
setIconProvider(java.util.function.Function<? super E,java.lang.String> iconProvider)
Sets the row icon provider for the Table.
|
void |
setItemClickAction(Action action)
Assign action to be executed on double click inside a table row.
|
void |
setItemDescriptionProvider(java.util.function.BiFunction<? super E,java.lang.String,java.lang.String> provider)
Sets the item description provider that is used for generating tooltip descriptions for items.
|
void |
setItems(TableItems<E> tableItems)
Sets an instance of
TableItems as the Table data source. |
void |
setMultiLineCells(boolean multiLineCells)
Sets whether multi-line display is enabled for cells containing several lines of text.
|
void |
setMultiSelect(boolean multiselect)
Sets whether multiple selection mode is enabled.
|
void |
setRequired(Table.Column<E> column,
boolean required,
java.lang.String message)
Sets whether the component inside a column must contain a non-null value.
|
void |
setRowHeaderMode(Table.RowHeaderMode mode)
Sets the row header mode.
|
void |
setRowHeaderWidth(int width)
Sets the width of row header column.
|
void |
setShowSelection(boolean showSelection)
Sets whether a current row is highlighted.
|
void |
setShowTotalAggregation(boolean showAggregation)
Shows in which aggregation the changes occurred: in the total or group.
|
void |
setSortable(boolean sortable)
Defines if sortable attribute can be changed for individual column or not.
|
void |
setStyleProvider(Table.StyleProvider<? super E> styleProvider)
Sets the cell style provider for the table.
All style providers added before this call will be removed. |
void |
setTextSelectionEnabled(boolean textSelectionEnabled)
Sets whether text selection in Table cells is enabled.
|
void |
showCustomPopup(Component popupComponent)
Shows popup inside of Table, relative to last cell click event.
Call this method from Table.Column.ClickEvent implementation. |
void |
showCustomPopupActions(java.util.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. |
void |
sort(java.lang.String columnId,
Table.SortDirection direction)
Sorts the Table data for passed column id in the chosen sort direction.
|
getSelected, getSingleSelected, isMultiSelect, setSelected, setSelected
getFrame, setFrame
addAction, addAction, getAction, getActionNN, getActions, removeAction, removeAction, removeAllActions
addStyleName, getAlignment, getHeight, getHeightSizeUnit, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, isEnabled, isEnabledRecursive, isResponsive, isVisible, isVisibleRecursive, removeStyleName, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapComposition, unwrapCompositionOrNull, unwrapOrNull, withUnwrapped, withUnwrappedComposition
isEditable, isEditableWithParent, setEditable
getButtonsPanel, setButtonsPanel
applyPresentation, applyPresentationAsDefault, getDefaultPresentationId, getDefaultSettings, getPresentations, loadPresentations, resetPresentation, setDefaultSettings
getContextHelpIconClickHandler, getContextHelpText, isContextHelpTextHtmlEnabled, setContextHelpIconClickHandler, setContextHelpText, setContextHelpTextHtmlEnabled
getIcon, setIcon, setIconFromSet
getLookupSelectedItems, setLookupSelectHandler
focus, getTabIndex, isFocusable, setFocusable, setTabIndex
isCaptionAsHtml, setCaptionAsHtml
getCaption, setCaption
getDescription, setDescription
isDescriptionAsHtml, setDescriptionAsHtml
isHtmlSanitizerEnabled, setHtmlSanitizerEnabled
getPagination, setPagination
static final java.lang.String NAME
static <T> org.springframework.core.ParameterizedTypeReference<Table<T>> of(java.lang.Class<T> itemClass)
@StudioElementsGroup(xmlElement="columns", caption="Columns", icon="io/jmix/ui/icon/element/columns.svg") java.util.List<Table.Column<E>> getColumns()
getNotCollapsedColumns()
@Nullable Table.Column<E> getColumn(java.lang.String id)
id
- the column idnull
if not foundvoid addColumn(Table.Column<E> column)
Note that column id should be an instance of MetaPropertyPath
.
column
- the column to addaddColumn(Column, int)
,
addColumn(Object)
,
addColumn(Object, int)
void addColumn(Table.Column<E> column, int index)
Note that column id should be an instance of MetaPropertyPath
.
column
- the column to addindex
- index of a new columnaddColumn(Column)
,
addColumn(Object)
,
addColumn(Object, int)
Table.Column<E> addColumn(java.lang.Object id)
id
- the column id or the instance of MetaPropertyPath
representing a relative path
to a property from certain MetaClass
addColumn(Column)
,
addColumn(Column, int)
,
addColumn(Object, int)
Table.Column<E> addColumn(java.lang.Object id, int index)
id
- the column id or the instance of MetaPropertyPath
representing a relative path
to a property from certain MetaClass
index
- index of a new columnaddColumn(Column)
,
addColumn(Column, int)
,
addColumn(Object)
void removeColumn(Table.Column<E> column)
null
.column
- the column to removejava.util.Map<java.lang.Object,java.lang.Object> getAggregationResults()
void setItems(@Nullable TableItems<E> tableItems)
TableItems
as the Table data source.tableItems
- the Table data source@Nullable TableItems<E> getItems()
getItems
in interface ListComponent<E>
void setRequired(Table.Column<E> column, boolean required, java.lang.String message)
column
- a columnrequired
- requiredmessage
- required message@StudioProperty(defaultValue="false") void setTextSelectionEnabled(boolean textSelectionEnabled)
textSelectionEnabled
- whether text selection in Table cells is enabledboolean isTextSelectionEnabled()
void setItemClickAction(Action action)
If such action is not set, the table responds to double click by trying to find and execute the following actions:
shortcut
property@Nullable Action getItemClickAction()
setItemClickAction(Action)
void setEnterPressAction(Action action)
If such action is not set, the table responds to pressing Enter by trying to find and execute the following actions:
setItemClickAction(Action)
shortcut
property@Nullable Action getEnterPressAction()
setEnterPressAction(Action)
java.util.List<Table.Column> getNotCollapsedColumns()
@StudioProperty(defaultValue="true") void setSortable(boolean sortable)
true
.sortable
- true
if individual column sortable
attribute can be set to true
, false
otherwiseboolean isSortable()
true
if individual column sortable
attribute can be set to true
, false
otherwise@StudioProperty(defaultValue="false") void setAggregatable(boolean aggregatable)
aggregatable
- whether aggregation is enabled.boolean isAggregatable()
@StudioProperty(defaultValue="true") void setShowTotalAggregation(boolean showAggregation)
showAggregation
- true
if the aggregation column should show
changes in total aggregation, false
if in
the group aggregationboolean isShowTotalAggregation()
true
if the aggregation column should show changes in
total aggregation, false
if in the group aggregation@StudioProperty(name="reorderingAllowed", defaultValue="true") void setColumnReorderingAllowed(boolean columnReorderingAllowed)
true
.columnReorderingAllowed
- specifies whether column reordering is allowedboolean getColumnReorderingAllowed()
true
.true
if reordering is allowedio.jmix.core.common.event.Subscription addColumnReorderListener(java.util.function.Consumer<Table.ColumnReorderEvent<E>> listener)
listener
- the listener to add@StudioProperty(defaultValue="true") void setColumnControlVisible(boolean columnControlVisible)
columnControlVisible
- whether user can hide columns using the
columnControlButton dropdown on the right side
of the table headerboolean getColumnControlVisible()
void requestFocus(E entity, java.lang.String columnId)
entity
- entitycolumnId
- column idvoid scrollTo(E entity)
entity
- entityvoid sort(java.lang.String columnId, Table.SortDirection direction)
columnId
- id of the column to sortdirection
- sort direction@Nullable Table.SortInfo getSortInfo()
void selectAll()
boolean isMultiLineCells()
@StudioProperty(defaultValue="false") void setMultiLineCells(boolean multiLineCells)
multiLineCells
- whether multi-line display is enabled for cells containing several
lines of textboolean isContextMenuEnabled()
@StudioProperty(defaultValue="true") void setContextMenuEnabled(boolean contextMenuEnabled)
contextMenuEnabled
- whether context menu is enabledvoid setRowHeaderWidth(int width)
width
- width of row header column in pxint getRowHeaderWidth()
@StudioProperty(name="multiselect", defaultValue="false") void setMultiSelect(boolean multiselect)
multiselect
- whether multiple selection mode is enabledvoid repaint()
@Nullable default java.lang.Object getSubPart(java.lang.String name)
getSubPart
in interface ActionsHolder
getSubPart
in interface HasSubParts
@StudioProperty(name="emptyStateMessage", type=LOCALIZED_STRING) void setEmptyStateMessage(@Nullable java.lang.String message)
message
- message that appears when Table is empty@Nullable java.lang.String getEmptyStateMessage()
@StudioProperty(name="emptyStateLinkMessage", type=LOCALIZED_STRING) void setEmptyStateLinkMessage(@Nullable java.lang.String linkMessage)
linkMessage
- message that appears when Table is emptysetEmptyStateLinkClickHandler(Consumer)
@Nullable java.lang.String getEmptyStateLinkMessage()
void setEmptyStateLinkClickHandler(@Nullable java.util.function.Consumer<Table.EmptyStateClickEvent<E>> handler)
handler
- handler to setsetEmptyStateLinkMessage(String)
@Nullable java.util.function.Consumer<Table.EmptyStateClickEvent<E>> getEmptyStateLinkClickHandler()
io.jmix.core.common.event.Subscription addColumnCollapseListener(java.util.function.Consumer<Table.ColumnCollapseEvent<E>> listener)
listener
- a listener to addSubscription
object@StudioProperty(type=ENUMERATION, defaultValue="NONE", options={"NONE","ICON"}) void setRowHeaderMode(Table.RowHeaderMode mode)
mode
- row header mode@StudioProperty(type=ENUMERATION, defaultValue="TOP", options={"TOP","BOTTOM"}) void setAggregationStyle(Table.AggregationStyle aggregationStyle)
aggregationStyle
- the location of the aggregation rowTable.AggregationStyle getAggregationStyle()
void setStyleProvider(@Nullable Table.StyleProvider<? super E> styleProvider)
styleProvider
- a style provider to setvoid addStyleProvider(Table.StyleProvider<? super E> styleProvider)
styleProvider
- a style provider to addvoid removeStyleProvider(Table.StyleProvider<? super E> styleProvider)
styleProvider
- a style provider to removevoid setIconProvider(@Nullable java.util.function.Function<? super E,java.lang.String> iconProvider)
iconProvider
- an icon provider to setsetRowHeaderMode(RowHeaderMode)
void setItemDescriptionProvider(@Nullable java.util.function.BiFunction<? super E,java.lang.String,java.lang.String> provider)
All unhandled exceptions from ItemDescriptionProvider in Web components by default are logged with ERROR level and not shown to users.
provider
- the item description provider to use or null
to remove a
previously set provider if any@Nullable java.util.function.BiFunction<? super E,java.lang.String,java.lang.String> getItemDescriptionProvider()
InstanceContainer<E> getInstanceContainer(E item)
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;
});
item
- entity itemvoid addGeneratedColumn(java.lang.String columnId, Table.ColumnGenerator<? super E> generator)
columnId
- column identifier as defined in XML descriptor.
May or may not correspond to an entity property.generator
- column generator instancevoid addGeneratedColumn(java.lang.String columnId, int index, Table.ColumnGenerator<? super E> generator)
columnId
- column identifier as defined in XML descriptor. May correspond to an entity propertyindex
- index of a new columngenerator
- column generator instancevoid addGeneratedColumn(java.lang.String columnId, Table.ColumnGenerator<? super E> generator, java.lang.Class<? extends Component> componentClass)
columnId
- column identifier as defined in XML descriptor.
May or may not correspond to an entity property.generator
- column generator instancecomponentClass
- class of components that generator will providevoid removeGeneratedColumn(java.lang.String columnId)
columnId
- the column idvoid addPrintable(java.lang.String columnId, Table.Printable<? super E,?> printable)
Table.Printable
representation for column. columnId
- column idprintable
- printable representationvoid removePrintable(java.lang.String columnId)
Table.Printable
representation of column. columnId
- column id@Nullable Table.Printable getPrintable(Table.Column column)
Table.Printable
representation for column.column
- table column@Nullable Table.Printable getPrintable(java.lang.String columnId)
Table.Printable
representation for column.columnId
- column idvoid setAggregationDistributionProvider(@Nullable Table.AggregationDistributionProvider<E> distributionProvider)
distributionProvider
- distribution provider@Nullable Table.AggregationDistributionProvider<E> getAggregationDistributionProvider()
void showCustomPopup(Component popupComponent)
Table.Column.ClickEvent
implementation.popupComponent
- popup contentvoid showCustomPopupActions(java.util.List<Action> actions)
Table.Column.ClickEvent
implementation.actions
- actions@StudioProperty(defaultValue="true") void setColumnHeaderVisible(boolean columnHeaderVisible)
columnHeaderVisible
- whether table header is displayedboolean isColumnHeaderVisible()
@StudioProperty(defaultValue="true") void setShowSelection(boolean showSelection)
showSelection
- whether a current row is highlightedboolean isShowSelection()
io.jmix.core.common.event.Subscription addSelectionListener(java.util.function.Consumer<Table.SelectionEvent<E>> listener)
listener
- the listener to register