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 type
- All 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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrid.Column.NestedNullBehaviorBehavior when parsing nested properties which may containnullvalues 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 protectedColumn(ValueProvider<T,V> valueProvider, ValueProvider<V,P> presentationProvider, Renderer<? super P> renderer)Constructs a new Column configuration with given renderer and value provider.protectedColumn(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.protectedColumn(ValueProvider<T,V> valueProvider, Renderer<? super V> renderer)Constructs a new Column configuration with given renderer and value provider.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckColumnIsAttached()Checks if column is attached and throws anIllegalStateExceptionif it is not.Grid.Column<T,V>clearExpandRatio()Clears the expand ratio for this column.StringgetAssistiveCaption()Gets the header caption for this column.StringgetCaption()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.intgetExpandRatio()Returns the column's expand ratio.protected Grid<T>getGrid()Gets the grid that this column belongs to.StringgetHidingToggleCaption()Gets the caption of the hiding toggle for this column.StringgetId()Returns the user-defined identifier for this column.doublegetMaximumWidth()Returns the maximum width for this column.doublegetMinimumWidth()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 ColumnStategetState()Returns the shared state for this connector.protected ColumnStategetState(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.doublegetWidth()Returns the width (in pixels).booleanisEditable()Gets whether this Column has a component displayed in Editor or not.booleanisHandleWidgetEvents()Gets whether Grid is handling the events in this Column from Component and Widgets.booleanisHidable()Returns whether this column can be hidden by the user.booleanisHidden()Returns whether this column is hidden.booleanisMinimumWidthFromContent()Gets whether the width of the contents in the column should be considered minimum width for this column.booleanisResizable()Returns whether this column can be resized by the user.booleanisSortable()Gets whether sorting is enabled for this column.booleanisSortableByUser()Gets whether the user can actually sort this column.booleanisWidthUndefined()Returns whether this column has an undefined width.protected voidreadDesign(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 voidwriteDesign(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, notnullrenderer- 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 type- Parameters:
valueProvider- the function to get values from items, notnullpresentationProvider- 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 type- Parameters:
valueProvider- the function to get values from items, notnullpresentationProvider- the function to get presentations from the value of this column, notnull. For more details, seesetRenderer(ValueProvider, Renderer)nestedNullBehavior- behavior on encountering nestednullvalues when reading the value from the beanrenderer- the presentation renderer, notnull- Since:
- 8.8
-
-
Method Detail
-
getState
protected ColumnState getState()
Description copied from class:AbstractClientConnectorReturns 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:
getStatein classAbstractClientConnector- Returns:
- The shared state for this connector. Never null.
-
getState
protected ColumnState getState(boolean markAsDirty)
Description copied from class:AbstractClientConnectorReturns the shared state for this connector.- Overrides:
getStatein classAbstractClientConnector- Parameters:
markAsDirty- true if the connector should automatically be marked dirty, false otherwise- Returns:
- The shared state for this connector. Never null.
- See Also:
AbstractClientConnector.getState()
-
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 inGrid.getColumn(String).The id is also used as the
backend sort propertyfor this column if no sort property or sort order provider has been set for this column.- Parameters:
id- the identifier string- Returns:
- 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 aftersetSortable(true)depends on theDataProviderand the defined sort order for this column. When using anInMemoryDataProvidersorting can be automatic.- Parameters:
sortable-trueto enable sorting for this column;falseto disable it- Returns:
- this column
-
isSortable
public boolean isSortable()
Gets whether sorting is enabled for this column.- Returns:
trueif the sorting is enabled for this column;falseif not
-
isSortableByUser
public boolean isSortableByUser()
Gets whether the user can actually sort this column.- Returns:
trueif the column can be sorted by the user;falseif not- Since:
- 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 column- Returns:
- 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 null- Returns:
- 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 usingsetSortProperty(String...).- Parameters:
comparator- the comparator to use when sorting data in this column- Returns:
- 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 by- Returns:
- 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 idwill be used as the sort property.- Parameters:
properties- the array of strings describing backend properties- Returns:
- 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 providesQuerySortOrderobjects to describe how to sort by this column.By default, the
column idwill be used as the sort property.- Parameters:
provider- the function to use when generating sort orders with the given direction- Returns:
- 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 direction- Returns:
- 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 null- Returns:
- this column
- Throws:
NullPointerException- ifcellStyleGeneratorisnull
-
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 theContentMode.PREFORMATTEDcontent mode.- Parameters:
cellDescriptionGenerator- the cell description generator to set, ornullto remove a previously set generator- Returns:
- this column
- See Also:
setDescriptionGenerator(DescriptionGenerator, ContentMode)
-
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, ornullto remove a previously set generatortooltipContentMode- the content mode for tooltips- Returns:
- this column
- Since:
- 8.2
- See Also:
setDescriptionGenerator(DescriptionGenerator)
-
getDescriptionGenerator
public DescriptionGenerator<T> getDescriptionGenerator()
Gets the description generator that is used for generating descriptions for cells.- Returns:
- the cell description generator, or
nullif 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.0to 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 grid- See Also:
setWidth(double)
-
getExpandRatio
public int getExpandRatio()
Returns the column's expand ratio.- Returns:
- the column's expand ratio
- See Also:
setExpandRatio(int)
-
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 IllegalStateExceptionReturns 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 column- Returns:
- 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 grid- Since:
- 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 column- Returns:
- the column itself
- Throws:
IllegalStateException- if the column is no longer attached to any grid- See Also:
setExpandRatio(int)
-
getMinimumWidth
public double getMinimumWidth()
Return the minimum width for this column.- Returns:
- the minimum width for this column
- See Also:
setMinimumWidth(double)
-
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
falseand 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-trueto reserve space for all contents,falseto allow the column to shrink smaller than the contents- Returns:
- the column itself
- Throws:
IllegalStateException- if the column is no longer attached to any grid- Since:
- 8.1
- See Also:
setMinimumWidth(double)
-
isMinimumWidthFromContent
public boolean isMinimumWidthFromContent()
Gets whether the width of the contents in the column should be considered minimum width for this column.- Returns:
trueto reserve space for all contents,falseto allow the column to shrink smaller than the contents- Since:
- 8.1
- See Also:
setMinimumWidthFromContent(boolean)
-
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 width- Returns:
- this column
- Throws:
IllegalStateException- if the column is no longer attached to any grid- See Also:
setExpandRatio(int)
-
getMaximumWidth
public double getMaximumWidth()
Returns the maximum width for this column.- Returns:
- the maximum width for this column
- See Also:
setMaximumWidth(double)
-
setResizable
public Grid.Column<T,V> setResizable(boolean resizable)
Sets whether this column can be resized by the user.- Parameters:
resizable-trueif this column should be resizable,falseotherwise- Returns:
- this column
- Throws:
IllegalStateException- if the column is no longer attached to any grid- Since:
- 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(String)
-
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 ishidable.The default value is
null, and in that case the column'sheader captionis 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 toggle- Returns:
- 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-trueto hide the column,falseto show- Returns:
- this column
- Throws:
IllegalStateException- if the column is no longer attached to any grid- Since:
- 7.5.0
-
isHidden
public boolean isHidden()
Returns whether this column is hidden. Default isfalse.- Returns:
trueif the column is currently hidden,falseotherwise- Since:
- 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-trueif the column may be hidable by the user via UI interaction- Returns:
- this column
- Since:
- 7.5.0
-
isHidable
public boolean isHidable()
Returns whether this column can be hidden by the user. Default isfalse.Note: the column can be programmatically hidden using
setHidden(boolean)regardless of the returned value.- Returns:
trueif the user can hide the column,falseif not- Since:
- 7.5.0
-
isResizable
public boolean isResizable()
Returns whether this column can be resized by the user. Default istrue.Note: the column can be programmatically resized using
setWidth(double)andsetWidthUndefined()regardless of the returned value.- Returns:
trueif this column is resizable,falseotherwise- Since:
- 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-trueif column is editable;falseif not- Returns:
- this column
- Throws:
IllegalStateException- if editable is true and column has no editor binding or component defined- See Also:
setEditorComponent(HasValue, Setter),setEditorBinding(Binding)
-
isEditable
public boolean isEditable()
Gets whether this Column has a component displayed in Editor or not.- Returns:
trueif the column displays an editor component;falseif not
-
setEditorBinding
public Grid.Column<T,V> setEditorBinding(Binder.Binding<T,?> binding)
Sets an editor binding for this column. TheBinder.Bindingis 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
HasValuethat the binding is defined to use must be aComponent.- Parameters:
binding- the binding to use for this column- Returns:
- 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
nullif no binding is configured - See Also:
setEditorBinding(Binding)
-
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. UsesetEditorBinding(Binding)to support more complex cases.Note: The same component cannot be used for multiple columns.
- Type Parameters:
C- a class that extends bothHasValueandComponent- Parameters:
editorComponent- the editor componentsetter- a setter that stores the component value in the row item- Returns:
- 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 anidand theGridhas 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 component- Returns:
- 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 renderer- Returns:
- 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 type- Parameters:
presentationProvider- the function to get presentations from the value of this column, notnullrenderer- 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
ComboBoxorTextFieldit might be problematic as the component gets re-rendered and might lose focus.- Parameters:
handleWidgetEvents-trueto handle events;falseto not- Returns:
- this column
- Since:
- 8.3
-
isHandleWidgetEvents
public boolean isHandleWidgetEvents()
Gets whether Grid is handling the events in this Column from Component and Widgets.- Returns:
trueif handling events;falseif not- Since:
- 8.3
- See Also:
setHandleWidgetEvents(boolean)
-
getGrid
protected Grid<T> getGrid()
Gets the grid that this column belongs to.- Returns:
- the grid that this column belongs to, or
nullif this column has not yet been associated with any grid
-
checkColumnIsAttached
protected void checkColumnIsAttached() throws IllegalStateExceptionChecks if column is attached and throws anIllegalStateExceptionif 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 context- Since:
- 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 context- Since:
- 7.5.0
-
-