T - the grid bean typeV - the column value typepublic static class Grid.Column<T,V> extends Grid.AbstractGridExtension<T>
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener| Modifier | Constructor and Description |
|---|---|
protected |
Column(ValueProvider<T,V> valueProvider,
Renderer<? super V> renderer)
Constructs a new Column configuration with given renderer and value
provider.
|
| Modifier and Type | Method and 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.
|
void |
generateData(T data,
elemental.json.JsonObject jsonObject)
Adds custom data for the given item to its serialized
JsonObject
representation. |
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.
|
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.
|
SerializableFunction<T,? extends 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 |
isHidable()
Returns whether this column can be hidden by the user.
|
boolean |
isHidden()
Returns whether this column is hidden.
|
boolean |
isResizable()
Returns whether this column can be resized by the user.
|
boolean |
isSortable()
Gets whether the user can sort this column or not.
|
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> |
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> |
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> |
setEditorComponent(C editorComponent)
Sets a component to use for editing values of this columns in the
editor row.
|
<C extends HasValue<V> & Component> |
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> |
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> |
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.
|
addComponentToGrid, extend, getInternalIdForColumn, getParent, removeComponentFromGridgetData, refresh, removeextend, getSupportedParentType, setParentaddAttachListener, addDetachListener, addExtension, 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, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource, updateDiffstateclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitdestroyAllData, destroyData, refreshDataaddAttachListener, addDetachListener, attach, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, getUI, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdprotected Column(ValueProvider<T,V> valueProvider, Renderer<? super V> renderer)
valueProvider - the function to get values from items, not
nullrenderer - the type of value, not nullpublic void generateData(T data, elemental.json.JsonObject jsonObject)
DataGeneratorJsonObject
representation. This JSON object will be sent to client-side
DataProvider.data - the data item being serializedjsonObject - the JSON object being sent to the clientprotected ColumnState getState()
AbstractClientConnector
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.
getState in class Grid.AbstractGridExtension<T>protected ColumnState getState(boolean markAsDirty)
AbstractClientConnectorgetState in class Grid.AbstractGridExtension<T>markAsDirty - true if the connector should automatically be marked dirty,
false otherwiseAbstractClientConnector.getState()public String getId()
public Grid.Column<T,V> setId(String id)
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.
id - the identifier stringsetSortProperty(String...),
setSortOrderProvider(SortOrderProvider)public SerializableFunction<T,? extends V> getValueProvider()
public Grid.Column<T,V> setSortable(boolean sortable)
sortable - true if the column can be sorted by the user;
false if notpublic boolean isSortable()
true if the column can be sorted by the user;
false if notpublic Grid.Column<T,V> setCaption(String caption)
caption - the header caption, not nullpublic String getCaption()
public Grid.Column<T,V> setComparator(SerializableComparator<T> comparator)
setSortProperty(String...).comparator - the comparator to use when sorting data in this columnpublic SerializableComparator<T> getComparator(SortDirection sortDirection)
sortDirection - the direction this column is sorted bypublic Grid.Column<T,V> setSortProperty(String... properties)
By default, the column id will be used as the
sort property.
properties - the array of strings describing backend propertiespublic Grid.Column<T,V> setSortOrderProvider(SortOrderProvider provider)
QuerySortOrder objects
to describe how to sort by this column.
By default, the column id will be used as the
sort property.
provider - the function to use when generating sort orders with the
given directionpublic Stream<QuerySortOrder> getSortOrder(SortDirection direction)
direction - the sorting directionsetSortProperty(String...),
setId(String),
setSortOrderProvider(SortOrderProvider)public Grid.Column<T,V> setStyleGenerator(StyleGenerator<T> cellStyleGenerator)
cellStyleGenerator - the cell style generator to set, not nullNullPointerException - if cellStyleGenerator is nullpublic StyleGenerator<T> getStyleGenerator()
public Grid.Column<T,V> setDescriptionGenerator(DescriptionGenerator<T> cellDescriptionGenerator)
cellDescriptionGenerator - the cell description generator to set, or
null to remove a previously set generatorpublic DescriptionGenerator<T> getDescriptionGenerator()
null if no
generator is setpublic Grid.Column<T,V> setExpandRatio(int expandRatio) throws IllegalStateException
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.
expandRatio - the expand ratio of this column. 0 to not have it
expand at all. A negative number to clear the expand
value.IllegalStateException - if the column is no longer attached to any gridsetWidth(double)public int getExpandRatio()
setExpandRatio(int)public Grid.Column<T,V> clearExpandRatio() throws IllegalStateException
Equal to calling setExpandRatio(-1)
IllegalStateException - if the column is no longer attached to any gridpublic double getWidth()
throws IllegalStateException
IllegalStateException - if the column is no longer attached to any gridpublic Grid.Column<T,V> setWidth(double pixelWidth) throws IllegalStateException, IllegalArgumentException
This overrides any configuration set by any of
setExpandRatio(int), setMinimumWidth(double) or
setMaximumWidth(double).
pixelWidth - the new pixel width of the columnIllegalStateException - if the column is no longer attached to any gridIllegalArgumentException - thrown if pixel width is less than zeropublic boolean isWidthUndefined()
IllegalStateException - if the column is no longer attached to any gridpublic Grid.Column<T,V> setWidthUndefined()
public Grid.Column<T,V> setMinimumWidth(double pixels) throws IllegalStateException
This defines the minimum guaranteed pixel width of the column when it is set to expand.
IllegalStateException - if the column is no longer attached to any gridsetExpandRatio(int)public double getMinimumWidth()
setMinimumWidth(double)public Grid.Column<T,V> setMaximumWidth(double pixels)
This defines the maximum allowed pixel width of the column when it is set to expand.
pixels - the maximum widthIllegalStateException - if the column is no longer attached to any gridsetExpandRatio(int)public double getMaximumWidth()
setMaximumWidth(double)public Grid.Column<T,V> setResizable(boolean resizable)
resizable - true if this column should be resizable,
false otherwiseIllegalStateException - if the column is no longer attached to any gridpublic String getHidingToggleCaption()
setHidingToggleCaption(String)public Grid.Column<T,V> setHidingToggleCaption(String hidingToggleCaption)
hidable.
The default value is null, and in that case the column's
header caption is used.
NOTE: setting this to empty string might cause the hiding toggle to not render correctly.
hidingToggleCaption - the text to show in the column hiding togglepublic Grid.Column<T,V> setHidden(boolean hidden)
hidden - true to hide the column, false
to showIllegalStateException - if the column is no longer attached to any gridpublic boolean isHidden()
false.true if the column is currently hidden,
false otherwisepublic Grid.Column<T,V> setHidable(boolean hidable)
hidable - true iff the column may be hidable by the
user via UI interactionpublic boolean isHidable()
false.
Note: the column can be programmatically hidden using
setHidden(boolean) regardless of the returned value.
true if the user can hide the column,
false if notpublic boolean isResizable()
true.
Note: the column can be programmatically resized using
setWidth(double) and setWidthUndefined() regardless
of the returned value.
true if this column is resizable, false
otherwisepublic Grid.Column<T,V> setEditable(boolean editable)
editable - true if column is editable; false if notsetEditorComponent(HasValue, Setter),
#setEditorBinding(Binding)public boolean isEditable()
true if the column displays an editor component;
false if notpublic Grid.Column<T,V> setEditorBinding(Binder.Binding<T,?> binding)
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 use
setEditorComponent(HasValue, Setter) if no validator or
converter is needed for the binding.
The HasValue that the binding is defined to use must be a
Component.
binding - the binding to use for this columnsetEditorComponent(HasValue, Setter),
Binder.Binding,
Grid.getEditor(),
Editor.getBinder()public Binder.Binding<T,?> getEditorBinding()
null if no binding
is configured#setEditorBinding(Binding)public <C extends HasValue<V> & Component> Grid.Column<T,V> setEditorComponent(C editorComponent, Setter<T,V> setter)
#setEditorBinding(Binding) to support more complex cases.
Note: The same component cannot be used for multiple columns.
editorComponent - the editor componentsetter - a setter that stores the component value in the row item#setEditorBinding(Binding),
Grid.getEditor(),
Binder.bind(HasValue, ValueProvider, Setter)public <F,C extends HasValue<F> & Component> Grid.Column<T,V> setEditorComponent(C editorComponent)
id and the Grid has been created using
Grid.Grid(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.
editorComponent - the editor component#setEditorBinding(Binding),
Grid.getEditor(),
Binder.bind(HasValue, String),
Grid.Grid(Class)public Grid.Column<T,V> setRenderer(Renderer<? super V> renderer)
renderer - the new rendererprotected Grid<T> getGrid()
null if
this column has not yet been associated with any gridprotected void checkColumnIsAttached()
throws IllegalStateException
IllegalStateException if it is not.IllegalStateException - if the column is no longer attached to any gridprotected void writeDesign(org.jsoup.nodes.Element element,
DesignContext designContext)
element - Element to write attributes intodesignContext - the design contextprotected void readDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
design - Element to read attributes fromdesignContext - the design contextCopyright © 2017 Vaadin Ltd. All rights reserved.