com.vaadin.ui.
Class Grid.Column<T,V>
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.server.AbstractExtension
-
- com.vaadin.ui.Grid.Column<T,V>
-
Type Parameters:
T
- the grid bean typeV
- the column value typeAll Implemented Interfaces:
MethodEventSource
,ClientConnector
,Extension
,Connector
,Serializable
public static class Grid.Column<T,V> extends AbstractExtension
This extension manages the configuration and data communication for a Column inside of a Grid component.
See Also:
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Grid.Column.NestedNullBehavior
Behavior when parsing nested properties which may contain
null
values in the property chain.-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Column(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer)
Constructs a new Column configuration with given renderer and value provider.
protected
Column(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer, Grid.Column.NestedNullBehavior nestedNullBehavior)
Constructs a new Column configuration with given renderer and value provider.
protected
Column(ValueProvider<T,V> valueProvider, Renderer<? super V> renderer)
Constructs a new Column configuration with given renderer and value provider.
-
Method Summary
All Methods Modifier and Type Method Description protected void
checkColumnIsAttached()
Checks if column is attached and throws an
IllegalStateException
if it is not.Grid.Column<T,V>
clearExpandRatio()
Clears the expand ratio for this column.
String
getAssistiveCaption()
Gets the header caption for this column.
String
getCaption()
Gets the header caption for this column.
SerializableComparator<T>
getComparator(SortDirection sortDirection)
Gets the comparator to use with in-memory sorting for this column when sorting in the given direction.
DescriptionGenerator<T>
getDescriptionGenerator()
Gets the description generator that is used for generating descriptions for cells.
Binder.Binding<T,?>
getEditorBinding()
Gets the binder binding that is currently used for this column.
int
getExpandRatio()
Returns the column's expand ratio.
protected Grid<T>
getGrid()
Gets the grid that this column belongs to.
String
getHidingToggleCaption()
Gets the caption of the hiding toggle for this column.
String
getId()
Returns the user-defined identifier for this column.
double
getMaximumWidth()
Returns the maximum width for this column.
double
getMinimumWidth()
Return the minimum width for this column.
ValueProvider<V,?>
getPresentationProvider()
Gets the function to get presentations from the value of data in this column, based on the row item.
Renderer<?>
getRenderer()
Gets the Renderer for this Column.
Stream<QuerySortOrder>
getSortOrder(SortDirection direction)
Gets the sort orders to use with back-end sorting for this column when sorting in the given direction.
protected ColumnState
getState()
Returns the shared state for this connector.
protected ColumnState
getState(boolean markAsDirty)
Returns the shared state for this connector.
StyleGenerator<T>
getStyleGenerator()
Gets the style generator that is used for generating styles for cells.
ValueProvider<T,V>
getValueProvider()
Gets the function used to produce the value for data in this column based on the row item.
double
getWidth()
Returns the width (in pixels).
boolean
isEditable()
Gets whether this Column has a component displayed in Editor or not.
boolean
isHandleWidgetEvents()
Gets whether Grid is handling the events in this Column from Component and Widgets.
boolean
isHidable()
Returns whether this column can be hidden by the user.
boolean
isHidden()
Returns whether this column is hidden.
boolean
isMinimumWidthFromContent()
Gets whether the width of the contents in the column should be considered minimum width for this column.
boolean
isResizable()
Returns whether this column can be resized by the user.
boolean
isSortable()
Gets whether sorting is enabled for this column.
boolean
isSortableByUser()
Gets whether the user can actually sort this column.
boolean
isWidthUndefined()
Returns whether this column has an undefined width.
protected void
readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the design attributes for this column from given element.
Grid.Column<T,V>
setAssistiveCaption(String caption)
Sets the header aria-label for this column.
Grid.Column<T,V>
setCaption(String caption)
Sets the header caption for this column.
Grid.Column<T,V>
setComparator(SerializableComparator<T> comparator)
Sets a comparator to use with in-memory sorting with this column.
Grid.Column<T,V>
setDescriptionGenerator(DescriptionGenerator<T> cellDescriptionGenerator)
Sets the description generator that is used for generating descriptions for cells in this column.
Grid.Column<T,V>
setDescriptionGenerator(DescriptionGenerator<T> cellDescriptionGenerator, ContentMode tooltipContentMode)
Sets the description generator that is used for generating descriptions for cells in this column.
Grid.Column<T,V>
setEditable(boolean editable)
Sets whether this Column has a component displayed in Editor or not.
Grid.Column<T,V>
setEditorBinding(Binder.Binding<T,?> binding)
Sets an editor binding for this column.
<F,C extends HasValue<F> & Component>
Grid.Column<T,V>setEditorComponent(C editorComponent)
Sets a component to use for editing values of this columns in the editor row.
<C extends HasValue<V> & Component>
Grid.Column<T,V>setEditorComponent(C editorComponent, Setter<T,V> setter)
Sets a component and setter to use for editing values of this column in the editor row.
Grid.Column<T,V>
setExpandRatio(int expandRatio)
Sets the ratio with which the column expands.
Grid.Column<T,V>
setHandleWidgetEvents(boolean handleWidgetEvents)
Sets whether Grid should handle events in this Column from Components and Widgets rendered by certain Renderers.
Grid.Column<T,V>
setHidable(boolean hidable)
Sets whether this column can be hidden by the user.
Grid.Column<T,V>
setHidden(boolean hidden)
Hides or shows the column.
Grid.Column<T,V>
setHidingToggleCaption(String hidingToggleCaption)
Sets the caption of the hiding toggle for this column.
Grid.Column<T,V>
setId(String id)
Sets the user-defined identifier to map this column.
Grid.Column<T,V>
setMaximumWidth(double pixels)
Sets the maximum width for this column.
Grid.Column<T,V>
setMinimumWidth(double pixels)
Sets the minimum width for this column.
Grid.Column<T,V>
setMinimumWidthFromContent(boolean minimumWidthFromContent)
Sets whether the width of the contents in the column should be considered minimum width for this column.
<P> Grid.Column<T,V>
setRenderer(ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer)
Sets the Renderer for this Column.
Grid.Column<T,V>
setRenderer(Renderer<? super V> renderer)
Sets the Renderer for this Column.
Grid.Column<T,V>
setResizable(boolean resizable)
Sets whether this column can be resized by the user.
Grid.Column<T,V>
setSortable(boolean sortable)
Sets whether the user can sort this column or not.
Grid.Column<T,V>
setSortOrderProvider(SortOrderProvider provider)
Sets the sort orders when sorting this column.
Grid.Column<T,V>
setSortProperty(String... properties)
Sets strings describing back end properties to be used when sorting this column.
Grid.Column<T,V>
setStyleGenerator(StyleGenerator<T> cellStyleGenerator)
Sets the style generator that is used for generating class names for cells in this column.
Grid.Column<T,V>
setWidth(double pixelWidth)
Sets the width (in pixels).
Grid.Column<T,V>
setWidthUndefined()
Marks the column width as undefined.
protected void
writeDesign(org.jsoup.nodes.Element element, DesignContext designContext)
Writes the design attributes for this column into given element.
-
Methods inherited from class com.vaadin.server.AbstractExtension
extend, getParent, getSupportedParentType, remove, setParent
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addListener, addListener, addListener, addMethodInvocationToQueue, attach, beforeClientResponse, createState, detach, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isConnectorEnabled, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstate
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
-
-
-
Constructor Detail
-
Column
protected Column(ValueProvider<T,V> valueProvider, Renderer<? super V> renderer)
Constructs a new Column configuration with given renderer and value provider.
Parameters:
valueProvider
- the function to get values from items, notnull
renderer
- the value renderer, notnull
-
Column
protected Column(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer)
Constructs a new Column configuration with given renderer and value provider.
For a more complete explanation on presentation provider, see
setRenderer(ValueProvider, Renderer)
.Type Parameters:
P
- the presentation typeParameters:
valueProvider
- the function to get values from items, notnull
presentationProvider
- the function to get presentations from the value of this column, notnull
. For more details, seesetRenderer(ValueProvider, Renderer)
renderer
- the presentation renderer, notnull
Since:
8.1
-
Column
protected Column(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer, Grid.Column.NestedNullBehavior nestedNullBehavior)
Constructs a new Column configuration with given renderer and value provider.
For a more complete explanation on presentation provider, see
setRenderer(ValueProvider, Renderer)
.Type Parameters:
P
- the presentation typeParameters:
valueProvider
- the function to get values from items, notnull
presentationProvider
- the function to get presentations from the value of this column, notnull
. For more details, seesetRenderer(ValueProvider, Renderer)
nestedNullBehavior
- behavior on encountering nestednull
values when reading the value from the beanrenderer
- the presentation renderer, notnull
Since:
8.8
-
-
Method Detail
-
getState
protected ColumnState getState()
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector. The shared state object is shared between the server connector and the client connector. Changes are only communicated from the server to the client and not in the other direction.
As a side effect, marks the connector dirty so any changes done to the state will be sent to the client. Use
getState(false)
to avoid marking the connector as dirty.Overrides:
getState
in classAbstractClientConnector
Returns:
The shared state for this connector. Never null.
-
getState
protected ColumnState getState(boolean markAsDirty)
Description copied from class:
AbstractClientConnector
Returns the shared state for this connector.
Overrides:
getState
in classAbstractClientConnector
Parameters:
markAsDirty
- true if the connector should automatically be marked dirty, false otherwiseReturns:
The shared state for this connector. Never null.
See Also:
-
getId
public String getId()
Returns the user-defined identifier for this column.
Returns:
the identifier string
-
setId
public Grid.Column<T,V> setId(String id)
Sets the user-defined identifier to map this column. The identifier can be used for example in
Grid.getColumn(String)
.The id is also used as the
backend sort property
for this column if no sort property or sort order provider has been set for this column.Parameters:
id
- the identifier stringReturns:
this column
See Also:
setSortProperty(String...)
,setSortOrderProvider(SortOrderProvider)
-
getValueProvider
public ValueProvider<T,V> getValueProvider()
Gets the function used to produce the value for data in this column based on the row item.
Returns:
the value provider function
Since:
8.0.3
-
getPresentationProvider
public ValueProvider<V,?> getPresentationProvider()
Gets the function to get presentations from the value of data in this column, based on the row item.
Returns:
the presentation provider function
Since:
8.13
-
setSortable
public Grid.Column<T,V> setSortable(boolean sortable)
Sets whether the user can sort this column or not. Whether the column is actually sortable after
setSortable(true)
depends on theDataProvider
and the defined sort order for this column. When using anInMemoryDataProvider
sorting can be automatic.Parameters:
sortable
-true
to enable sorting for this column;false
to disable itReturns:
this column
-
isSortable
public boolean isSortable()
Gets whether sorting is enabled for this column.
Returns:
true
if the sorting is enabled for this column;false
if not
-
isSortableByUser
public boolean isSortableByUser()
Gets whether the user can actually sort this column.
Returns:
true
if the column can be sorted by the user;false
if notSince:
8.3.2
-
setAssistiveCaption
public Grid.Column<T,V> setAssistiveCaption(String caption)
Sets the header aria-label for this column.
Parameters:
caption
- the header aria-label, null removes the aria-label from this columnReturns:
this column
Since:
8.2
-
getAssistiveCaption
public String getAssistiveCaption()
Gets the header caption for this column.
Returns:
header caption
Since:
8.2
-
setCaption
public Grid.Column<T,V> setCaption(String caption)
Sets the header caption for this column.
Parameters:
caption
- the header caption, not nullReturns:
this column
-
getCaption
public String getCaption()
Gets the header caption for this column.
Returns:
header caption
-
setComparator
public Grid.Column<T,V> setComparator(SerializableComparator<T> comparator)
Sets a comparator to use with in-memory sorting with this column. Sorting with a back-end is done using
setSortProperty(String...)
.Parameters:
comparator
- the comparator to use when sorting data in this columnReturns:
this column
-
getComparator
public SerializableComparator<T> getComparator(SortDirection sortDirection)
Gets the comparator to use with in-memory sorting for this column when sorting in the given direction.
Parameters:
sortDirection
- the direction this column is sorted byReturns:
comparator for this column
-
setSortProperty
public Grid.Column<T,V> setSortProperty(String... properties)
Sets strings describing back end properties to be used when sorting this column.
By default, the
column id
will be used as the sort property.Parameters:
properties
- the array of strings describing backend propertiesReturns:
this column
-
setSortOrderProvider
public Grid.Column<T,V> setSortOrderProvider(SortOrderProvider provider)
Sets the sort orders when sorting this column. The sort order provider is a function which provides
QuerySortOrder
objects to describe how to sort by this column.By default, the
column id
will be used as the sort property.Parameters:
provider
- the function to use when generating sort orders with the given directionReturns:
this column
-
getSortOrder
public Stream<QuerySortOrder> getSortOrder(SortDirection direction)
Gets the sort orders to use with back-end sorting for this column when sorting in the given direction.
Parameters:
direction
- the sorting directionReturns:
stream of sort orders
See Also:
setSortProperty(String...)
,setId(String)
,setSortOrderProvider(SortOrderProvider)
-
setStyleGenerator
public Grid.Column<T,V> setStyleGenerator(StyleGenerator<T> cellStyleGenerator)
Sets the style generator that is used for generating class names for cells in this column. Returning null from the generator results in no custom style name being set. Note: The style generator is applied only to the body cells, not to the Editor.
Parameters:
cellStyleGenerator
- the cell style generator to set, not nullReturns:
this column
Throws:
NullPointerException
- ifcellStyleGenerator
isnull
-
getStyleGenerator
public StyleGenerator<T> getStyleGenerator()
Gets the style generator that is used for generating styles for cells.
Returns:
the cell style generator
-
setDescriptionGenerator
public Grid.Column<T,V> setDescriptionGenerator(DescriptionGenerator<T> cellDescriptionGenerator)
Sets the description generator that is used for generating descriptions for cells in this column. This method uses the
ContentMode.PREFORMATTED
content mode.Parameters:
cellDescriptionGenerator
- the cell description generator to set, ornull
to remove a previously set generatorReturns:
this column
See Also:
-
setDescriptionGenerator
public Grid.Column<T,V> setDescriptionGenerator(DescriptionGenerator<T> cellDescriptionGenerator, ContentMode tooltipContentMode)
Sets the description generator that is used for generating descriptions for cells in this column. This method uses the given content mode.
Parameters:
cellDescriptionGenerator
- the cell description generator to set, ornull
to remove a previously set generatortooltipContentMode
- the content mode for tooltipsReturns:
this column
Since:
8.2
See Also:
-
getDescriptionGenerator
public DescriptionGenerator<T> getDescriptionGenerator()
Gets the description generator that is used for generating descriptions for cells.
Returns:
the cell description generator, or
null
if no generator is set
-
setExpandRatio
public Grid.Column<T,V> setExpandRatio(int expandRatio) throws IllegalStateException
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 grid 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.Returns:
this column
Throws:
IllegalStateException
- if the column is no longer attached to any gridSee Also:
-
getExpandRatio
public int getExpandRatio()
Returns the column's expand ratio.
Returns:
the column's expand ratio
See Also:
-
clearExpandRatio
public Grid.Column<T,V> clearExpandRatio() throws IllegalStateException
Clears the expand ratio for this column.
Equal to calling
setExpandRatio(-1)
Returns:
this column
Throws:
IllegalStateException
- if the column is no longer attached to any grid
-
getWidth
public double getWidth() throws IllegalStateException
Returns the width (in pixels). By default a column width is -1.0 (undefined).
Returns:
the width in pixels of the column
Throws:
IllegalStateException
- if the column is no longer attached to any grid
-
setWidth
public Grid.Column<T,V> setWidth(double pixelWidth) throws IllegalStateException, IllegalArgumentException
Sets the width (in pixels).
This overrides any configuration set by any of
setExpandRatio(int)
,setMinimumWidth(double)
orsetMaximumWidth(double)
.Parameters:
pixelWidth
- the new pixel width of the columnReturns:
the column itself
Throws:
IllegalStateException
- if the column is no longer attached to any gridIllegalArgumentException
- thrown if pixel width is less than zero
-
isWidthUndefined
public boolean isWidthUndefined()
Returns whether this column has an undefined width.
Returns:
whether the width is undefined
Throws:
IllegalStateException
- if the column is no longer attached to any gridSince:
7.6
-
setWidthUndefined
public Grid.Column<T,V> setWidthUndefined()
Marks the column width as undefined. An undefined width means the grid is free to resize the column based on the cell contents and available space in the grid.
Returns:
the column itself
-
setMinimumWidth
public Grid.Column<T,V> setMinimumWidth(double pixels) throws IllegalStateException
Sets the minimum width for this column.
This defines the minimum guaranteed pixel width of the column when it is set to expand. Note: Value -1 is not accepted, use
setWidthUndefined()
instead.Parameters:
pixels
- the minimum width for the columnReturns:
the column itself
Throws:
IllegalStateException
- if the column is no longer attached to any gridSee Also:
-
getMinimumWidth
public double getMinimumWidth()
Return the minimum width for this column.
Returns:
the minimum width for this column
See Also:
-
setMinimumWidthFromContent
public Grid.Column<T,V> setMinimumWidthFromContent(boolean minimumWidthFromContent) throws IllegalStateException
Sets whether the width of the contents in the column should be considered minimum width for this column.
If this is set to
true
(default for backwards compatibility), then a column will not shrink to smaller than the width required to show the contents available when calculating the widths (only the widths of the initially rendered rows are considered).If this is set to
false
and the column has been set to expand using #setExpandRatio(int), then the contents of the column will be ignored when calculating the width, and the column will thus shrink down to the minimum width defined by #setMinimumWidth(double) if necessary.Parameters:
minimumWidthFromContent
-true
to reserve space for all contents,false
to allow the column to shrink smaller than the contentsReturns:
the column itself
Throws:
IllegalStateException
- if the column is no longer attached to any gridSince:
8.1
See Also:
-
isMinimumWidthFromContent
public boolean isMinimumWidthFromContent()
Gets whether the width of the contents in the column should be considered minimum width for this column.
Returns:
true
to reserve space for all contents,false
to allow the column to shrink smaller than the contentsSince:
8.1
See Also:
-
setMaximumWidth
public Grid.Column<T,V> 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 maximum widthReturns:
this column
Throws:
IllegalStateException
- if the column is no longer attached to any gridSee Also:
-
getMaximumWidth
public double getMaximumWidth()
Returns the maximum width for this column.
Returns:
the maximum width for this column
See Also:
-
setResizable
public Grid.Column<T,V> setResizable(boolean resizable)
Sets whether this column can be resized by the user.
Parameters:
resizable
-true
if this column should be resizable,false
otherwiseReturns:
this column
Throws:
IllegalStateException
- if the column is no longer attached to any gridSince:
7.6
-
getHidingToggleCaption
public String getHidingToggleCaption()
Gets the caption of the hiding toggle for this column.
Returns:
the caption for the hiding toggle for this column
Since:
7.5.0
See Also:
-
setHidingToggleCaption
public Grid.Column<T,V> setHidingToggleCaption(String hidingToggleCaption)
Sets the caption of the hiding toggle for this column. Shown in the toggle for this column in the grid's sidebar when the column is
hidable
.The default value is
null
, and in that case the column'sheader caption
is used.NOTE: setting this to empty string might cause the hiding toggle to not render correctly.
Parameters:
hidingToggleCaption
- the text to show in the column hiding toggleReturns:
the column itself
Since:
7.5.0
-
setHidden
public Grid.Column<T,V> setHidden(boolean hidden)
Hides or shows the column. By default columns are visible before explicitly hiding them.
Parameters:
hidden
-true
to hide the column,false
to showReturns:
this column
Throws:
IllegalStateException
- if the column is no longer attached to any gridSince:
7.5.0
-
isHidden
public boolean isHidden()
Returns whether this column is hidden. Default is
false
.Returns:
true
if the column is currently hidden,false
otherwiseSince:
7.5.0
-
setHidable
public Grid.Column<T,V> setHidable(boolean hidable)
Sets whether this column can be hidden by the user. Hidable columns can be hidden and shown via the sidebar menu.
Parameters:
hidable
-true
if the column may be hidable by the user via UI interactionReturns:
this column
Since:
7.5.0
-
isHidable
public boolean isHidable()
Returns whether this column can be hidden by the user. Default is
false
.Note: the column can be programmatically hidden using
setHidden(boolean)
regardless of the returned value.Returns:
true
if the user can hide the column,false
if notSince:
7.5.0
-
isResizable
public 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)
andsetWidthUndefined()
regardless of the returned value.Returns:
true
if this column is resizable,false
otherwiseSince:
7.6
-
setEditable
public Grid.Column<T,V> setEditable(boolean editable) throws IllegalStateException
Sets whether this Column has a component displayed in Editor or not. A column can only be editable if an editor component or binding has been set.
Parameters:
editable
-true
if column is editable;false
if notReturns:
this column
Throws:
IllegalStateException
- if editable is true and column has no editor binding or component definedSee Also:
setEditorComponent(HasValue, Setter)
,setEditorBinding(Binding)
-
isEditable
public boolean isEditable()
Gets whether this Column has a component displayed in Editor or not.
Returns:
true
if the column displays an editor component;false
if not
-
setEditorBinding
public Grid.Column<T,V> setEditorBinding(Binder.Binding<T,?> binding)
Sets an editor binding for this column. The
Binder.Binding
is used when a row is in editor mode to define how to populate an editor component based on the edited row and how to update an item based on the value in the editor component.To create a binding to use with a column, define a binding for the editor binder (
grid.getEditor().getBinder()
) using e.g.Binder.forField(HasValue)
. You can also usesetEditorComponent(HasValue, Setter)
if no validator or converter is needed for the binding.The
HasValue
that the binding is defined to use must be aComponent
.Parameters:
binding
- the binding to use for this columnReturns:
this column
See Also:
setEditorComponent(HasValue, Setter)
,Binder.Binding
,Grid.getEditor()
,Editor.getBinder()
-
getEditorBinding
public Binder.Binding<T,?> getEditorBinding()
Gets the binder binding that is currently used for this column.
Returns:
the used binder binding, or
null
if no binding is configuredSee Also:
-
setEditorComponent
public <C extends HasValue<V> & Component> Grid.Column<T,V> setEditorComponent(C editorComponent, Setter<T,V> setter)
Sets a component and setter to use for editing values of this column in the editor row. This is a shorthand for use in simple cases where no validator or converter is needed. Use
setEditorBinding(Binding)
to support more complex cases.Note: The same component cannot be used for multiple columns.
Type Parameters:
C
- a class that extends bothHasValue
andComponent
Parameters:
editorComponent
- the editor componentsetter
- a setter that stores the component value in the row itemReturns:
this column
See Also:
setEditorBinding(Binding)
,Grid.getEditor()
,Binder.bind(HasValue, ValueProvider, Setter)
-
setEditorComponent
public <F,C extends HasValue<F> & Component> Grid.Column<T,V> setEditorComponent(C editorComponent)
Sets a component to use for editing values of this columns in the editor row. This method can only be used if the column has an
id
and theGrid
has been created usingGrid(Class)
or some other way that allows finding properties based on property names.This is a shorthand for use in simple cases where no validator or converter is needed. Use
setEditorBinding(Binding)
to support more complex cases.Note: The same component cannot be used for multiple columns.
Type Parameters:
F
- a value typeC
- a class that extends bothHasValue
(for type<F>
) andComponent
Parameters:
editorComponent
- the editor componentReturns:
this column
See Also:
setEditorBinding(Binding)
,Grid.getEditor()
,Binder.bind(HasValue, String)
,Grid(Class)
-
setRenderer
public Grid.Column<T,V> setRenderer(Renderer<? super V> renderer)
Sets the Renderer for this Column. Setting the renderer will cause all currently available row data to be recreated and sent to the client. Note: Setting a new renderer will reset presentation provider if it exists.
Parameters:
renderer
- the new rendererReturns:
this column
Since:
8.0.3
-
setRenderer
public <P> Grid.Column<T,V> setRenderer(ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer)
Sets the Renderer for this Column. Setting the renderer will cause all currently available row data to be recreated and sent to the client.
The presentation provider is a method that takes the value of this column on a single row, and maps that to a value that the renderer accepts. This feature can be used for storing a complex value in a column for editing, but providing a simplified presentation for the user when not editing.
Type Parameters:
P
- the presentation typeParameters:
presentationProvider
- the function to get presentations from the value of this column, notnull
renderer
- the new renderer, notnull
Returns:
this column
Since:
8.1
-
getRenderer
public Renderer<?> getRenderer()
Gets the Renderer for this Column.
Returns:
the renderer
Since:
8.1
-
setHandleWidgetEvents
public Grid.Column<T,V> setHandleWidgetEvents(boolean handleWidgetEvents)
Sets whether Grid should handle events in this Column from Components and Widgets rendered by certain Renderers. By default the events are not handled.
Note: Enabling this feature will for example select a row when a component is clicked. For example in the case of a
ComboBox
orTextField
it might be problematic as the component gets re-rendered and might lose focus.Parameters:
handleWidgetEvents
-true
to handle events;false
to notReturns:
this column
Since:
8.3
-
isHandleWidgetEvents
public boolean isHandleWidgetEvents()
Gets whether Grid is handling the events in this Column from Component and Widgets.
Returns:
true
if handling events;false
if notSince:
8.3
See Also:
-
getGrid
protected Grid<T> getGrid()
Gets the grid that this column belongs to.
Returns:
the grid that this column belongs to, or
null
if this column has not yet been associated with any grid
-
checkColumnIsAttached
protected void checkColumnIsAttached() throws IllegalStateException
Checks if column is attached and throws an
IllegalStateException
if it is not.Throws:
IllegalStateException
- if the column is no longer attached to any grid
-
writeDesign
protected void writeDesign(org.jsoup.nodes.Element element, DesignContext designContext)
Writes the design attributes for this column into given element.
Parameters:
element
- Element to write attributes intodesignContext
- the design contextSince:
7.5.0
-
readDesign
protected void readDesign(org.jsoup.nodes.Element design, DesignContext designContext)
Reads the design attributes for this column from given element.
Parameters:
design
- Element to read attributes fromdesignContext
- the design contextSince:
7.5.0
-
-