public static class Grid.Column extends Object implements Serializable
Grid.getColumn(Object propertyId)
.Modifier and Type | Method and Description |
---|---|
protected void |
checkColumnIsAttached()
Checks if column is attached and throws an
IllegalStateException if it is not |
Grid.Column |
clearExpandRatio()
Clears the expand ratio for this column.
|
Converter<?,?> |
getConverter()
Returns the converter instance used by this column.
|
Field<?> |
getEditorField()
Returns the editor field used to edit the properties in this column
when the item editor is active.
|
int |
getExpandRatio()
Returns the column's expand ratio.
|
String |
getHeaderCaption()
Returns the caption of the header.
|
String |
getHidingToggleCaption()
Gets the caption of the hiding toggle for this column.
|
double |
getMaximumWidth()
Returns the maximum width for this column.
|
double |
getMinimumWidth()
Return the minimum width for this column.
|
Object |
getPropertyId()
Returns the property id for the backing property of this Column
|
Renderer<?> |
getRenderer()
Returns the renderer instance used by this column.
|
double |
getWidth()
Returns the width (in pixels).
|
boolean |
isEditable()
Returns whether the properties corresponding to this column should be
editable when the item editor is active.
|
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()
Returns whether the user can sort the grid by 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 |
setConverter(Converter<?,?> converter)
Sets the converter used to convert from the property value type to
the renderer presentation type.
|
Grid.Column |
setEditable(boolean editable)
Sets whether the properties corresponding to this column should be
editable when the item editor is active.
|
Grid.Column |
setEditorField(Field<?> editor)
Sets the field component used to edit the properties in this column
when the item editor is active.
|
Grid.Column |
setExpandRatio(int expandRatio)
Sets the ratio with which the column expands.
|
Grid.Column |
setHeaderCaption(String caption)
Sets the caption of the header.
|
Grid.Column |
setHidable(boolean hidable)
Sets whether this column can be hidden by the user.
|
Grid.Column |
setHidden(boolean hidden)
Hides or shows the column.
|
Grid.Column |
setHidingToggleCaption(String hidingToggleCaption)
Sets the caption of the hiding toggle for this column.
|
Grid.Column |
setLastFrozenColumn()
Sets this column as the last frozen column in its grid.
|
Grid.Column |
setMaximumWidth(double pixels)
Sets the maximum width for this column.
|
Grid.Column |
setMinimumWidth(double pixels)
Sets the minimum width for this column.
|
Grid.Column |
setRenderer(Renderer<?> renderer)
Sets the renderer for this column.
|
<T> Grid.Column |
setRenderer(Renderer<T> renderer,
Converter<? extends T,?> converter)
Sets the renderer for this column and the converter used to convert
from the property value type to the renderer presentation type.
|
Grid.Column |
setResizable(boolean resizable)
Sets whether this column can be resized by the user.
|
Grid.Column |
setSortable(boolean sortable)
Sets whether this column is sortable by the user.
|
Grid.Column |
setWidth(double pixelWidth)
Sets the width (in pixels).
|
Grid.Column |
setWidthUndefined()
Marks the column width as undefined.
|
String |
toString() |
protected void |
writeDesign(org.jsoup.nodes.Element design,
DesignContext designContext)
Writes the design attributes for this column into given element.
|
public Object getPropertyId()
public String getHeaderCaption() throws IllegalStateException
IllegalStateException
- if the column no longer is attached to the gridpublic Grid.Column setHeaderCaption(String caption) throws IllegalStateException
setHidingToggleCaption(String)
.caption
- the text to show in the captionIllegalStateException
- if the column is no longer attached to any gridpublic String getHidingToggleCaption() throws IllegalStateException
IllegalStateException
- if the column is no longer attached to any gridsetHidingToggleCaption(String)
public Grid.Column setHidingToggleCaption(String hidingToggleCaption) throws IllegalStateException
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 toggleIllegalStateException
- 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 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 setWidthUndefined()
protected void checkColumnIsAttached() throws IllegalStateException
IllegalStateException
if it is notIllegalStateException
- if the column is no longer attached to any gridpublic Grid.Column setLastFrozenColumn()
IllegalArgumentException
- if the column is no longer attached to any gridGrid.setFrozenColumnCount(int)
public Grid.Column setRenderer(Renderer<?> renderer)
If a suitable converter isn't defined explicitly, the session converter factory is used to find a compatible converter.
renderer
- the renderer to useIllegalArgumentException
- if no compatible converter could be foundVaadinSession.getConverterFactory()
,
ConverterUtil.getConverter(Class, Class, VaadinSession)
,
setConverter(Converter)
public <T> Grid.Column setRenderer(Renderer<T> renderer, Converter<? extends T,?> converter)
renderer
- the renderer to use, cannot be nullconverter
- the converter to useIllegalArgumentException
- if the renderer is already associated with a grid columnpublic Grid.Column setConverter(Converter<?,?> converter) throws IllegalArgumentException
converter
- the converter to use, or null
to not use any
convertersIllegalArgumentException
- if the types are not compatiblepublic Renderer<?> getRenderer()
public Converter<?,?> getConverter()
public Grid.Column setSortable(boolean sortable)
sortable
- true
if the user should be able to sort the
column, false
otherwiseIllegalStateException
- if the data source of the Grid does not implement
Container.Sortable
IllegalStateException
- if the data source does not support sorting by the
property associated with this columnpublic boolean isSortable()
Note: it is possible to sort by this column programmatically using the Grid#sort methods regardless of the returned value.
true
if the column is sortable by the user,
false
otherwisepublic Grid.Column 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 clearExpandRatio() throws IllegalStateException
Equal to calling setExpandRatio(-1)
IllegalStateException
- if the column is no longer attached to any gridpublic Grid.Column 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 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 setEditable(boolean editable)
Values in non-editable columns are currently not displayed when the editor is active, but this will probably change in the future. They are not automatically assigned an editor field and, if one is manually assigned, it is not used. Columns that cannot (or should not) be edited even in principle should be set non-editable.
editable
- true
if this column should be editable,
false
otherwiseIllegalStateException
- if the editor is currently activeGrid.editItem(Object)
,
Grid.isEditorActive()
public boolean isEditable()
true
if this column is editable, false
otherwiseGrid.editItem(Object)
,
setEditable(boolean)
public Grid.Column setEditorField(Field<?> editor)
Grid.editItem(Object)
.
Setting the field to null
clears any previously set
field, causing a new field to be created the next time the item
editor is opened.
editor
- the editor fieldpublic Field<?> getEditorField()
editable
.
When editItem
is called, fields are
automatically created and bound for any unbound properties.
Getting a field before the editor has been opened depends on special
support from the FieldGroup
in use. Using this method with a
user-provided FieldGroup
might cause
BindException
to be thrown.
null
if the respective
column is not editableIllegalArgumentException
- if there is no column for the provided property idFieldGroup.BindException
- if no field has been configured and there is a problem
building or bindingpublic Grid.Column setHidden(boolean hidden)
hidden
- true
to hide the column, false
to showpublic boolean isHidden()
false
.true
if the column is currently hidden,
false
otherwisepublic Grid.Column 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 Grid.Column setResizable(boolean resizable)
resizable
- true
if this column should be resizable,
false
otherwisepublic 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
otherwiseprotected void writeDesign(org.jsoup.nodes.Element design, DesignContext designContext)
design
- 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 © 2021 Vaadin Ltd. All rights reserved.