Class FGrid.Column
- All Implemented Interfaces:
Serializable
- Enclosing class:
FGrid
FGrid.getColumn(Object propertyId).- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks if column is attached and throws anIllegalStateExceptionif it is notClears the expand ratio for this column.booleanConverter<?, ?> Returns the converter instance used by this column.Field<?> Returns the editor field used to edit the properties in this column when the item editor is active.intReturns the column's expand ratio.Returns the caption of the header.doubleReturns the maximum width for this column.doubleReturn the minimum width for this column.Returns the property id for the backing property of this Columncom.vaadin.flow.data.renderer.Renderer<?> Returns the renderer instance used by this column.doublegetWidth()Returns the width (in pixels).inthashCode()booleanReturns whether the properties corresponding to this column should be editable when the item editor is active.booleanReturns whether this column can be hidden by the user.booleanisHidden()Returns whether this column is hidden.booleanReturns whether this column can be resized by the user.booleanReturns whether the user can sort the grid by this column.booleanReturns whether this column has an undefined width.setConverter(Converter<?, ?> converter) Sets the converter used to convert from the property value type to the renderer presentation type.setEditable(boolean editable) Sets whether the properties corresponding to this column should be editable when the item editor is active.setEditorField(Field<?> editor) Sets the field component used to edit the properties in this column when the item editor is active.setExpandRatio(int expandRatio) Sets the ratio with which the column expands.setHeaderCaption(String caption) Sets the caption of the header.setHidable(boolean hidable) Sets whether this column can be hidden by the user.setHidden(boolean hidden) Hides or shows the column.Sets this column as the last frozen column in its grid.setMaximumWidth(double pixels) Sets the maximum width for this column.setMinimumWidth(double pixels) Sets the minimum width for this column.setRenderer(FGrid.AbstractRenderer<?> renderer) Sets the V7 renderer for this column.<T> FGrid.ColumnsetRenderer(FGrid.AbstractRenderer<?> 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.setRenderer(com.vaadin.flow.data.renderer.Renderer<?> renderer) Sets the renderer for this column.<T> FGrid.ColumnsetRenderer(com.vaadin.flow.data.renderer.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.setResizable(boolean resizable) Sets whether this column can be resized by the user.setSortable(boolean sortable) Sets whether this column is sortable by the user.setWidth(double pixelWidth) Sets the width (in pixels).Marks the column width as undefined.toString()
-
Method Details
-
getPropertyId
Returns the property id for the backing property of this Column- Returns:
- property id
-
getHeaderCaption
Returns the caption of the header. By default the header caption is the property id of the column.- Returns:
- the text in the default row of header.
- Throws:
IllegalStateException- if the column no longer is attached to the grid
-
setHeaderCaption
Sets the caption of the header. This caption is also used as the hiding toggle caption.- Parameters:
caption- the text to show in the caption- Returns:
- the column itself
- Throws:
IllegalStateException- if the column is no longer attached to any grid
-
getWidth
Returns the width (in pixels). By default a column is 100px wide.- Returns:
- the width in pixels of the column
- Throws:
IllegalStateException- if the column is no longer attached to any grid
-
setWidth
public FGrid.Column setWidth(double pixelWidth) throws IllegalStateException, IllegalArgumentException Sets the width (in pixels).This overrides any configuration set by any of
setExpandRatio(int).- 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
-
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
-
setLastFrozenColumn
Sets this column as the last frozen column in its grid.- Returns:
- the column itself
- Throws:
IllegalArgumentException- if the column is no longer attached to any grid- See Also:
-
setSortable
Sets whether this column is sortable by the user. The grid can be sorted by a sortable column by clicking or tapping the column's default header. Programmatic sorting using the Grid#sort methods is not affected by this setting.- Parameters:
sortable-trueif the user should be able to sort the column,falseotherwise- Returns:
- the column itself
- Throws:
IllegalStateException- if the data source of the Grid does not implementContainer.SortableIllegalStateException- if the data source does not support sorting by the property associated with this column
-
isSortable
public boolean isSortable()Returns whether the user can sort the grid by this column.Note: it is possible to sort by this column programmatically using the Grid#sort methods regardless of the returned value.
- Returns:
trueif the column is sortable by the user,falseotherwise
-
toString
-
setExpandRatio
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.- Throws:
IllegalStateException- if the column is no longer attached to any grid- See Also:
-
getExpandRatio
public int getExpandRatio()Returns the column's expand ratio.- Returns:
- the column's expand ratio
- See Also:
-
clearExpandRatio
Clears the expand ratio for this column.Equal to calling
setExpandRatio(-1)- Throws:
IllegalStateException- if the column is no longer attached to any grid
-
setMinimumWidth
Sets the minimum width for this column.This defines the minimum guaranteed pixel width of the column when it is set to expand.
- Throws:
IllegalStateException- if the column is no longer attached to any grid- See Also:
-
getMinimumWidth
public double getMinimumWidth()Return the minimum width for this column.- Returns:
- the minimum width for this column
- See Also:
-
setMaximumWidth
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- Throws:
IllegalStateException- if the column is no longer attached to any grid- See Also:
-
getMaximumWidth
public double getMaximumWidth()Returns the maximum width for this column.- Returns:
- the maximum width for this column
- See Also:
-
setEditable
Sets whether the properties corresponding to this column should be editable when the item editor is active. By default columns are 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.
- Parameters:
editable-trueif this column should be editable,falseotherwise- Returns:
- this column
- Throws:
IllegalStateException- if the editor is currently active- See Also:
-
isEditable
public boolean isEditable()Returns whether the properties corresponding to this column should be editable when the item editor is active.- Returns:
trueif this column is editable,falseotherwise- See Also:
-
setEditorField
Sets the field component used to edit the properties in this column when the item editor is active. If an item has not been set, then the binding is postponed until the item is set usingFGrid.editItem(Object).Setting the field to
nullclears any previously set field, causing a new field to be created the next time the item editor is opened.- Parameters:
editor- the editor field- Returns:
- this column
-
getEditorField
Returns the editor field used to edit the properties in this column when the item editor is active. Returns null if the column is noteditable.When
editItemis 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
FieldGroupin use. Using this method with a user-providedFieldGroupmight causeBindExceptionto be thrown.- Returns:
- the bound field; or
nullif the respective column is not editable - Throws:
IllegalArgumentException- if there is no column for the provided property idFieldGroup.BindException- if no field has been configured and there is a problem building or binding
-
setHidden
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
-
isHidden
public boolean isHidden()Returns whether this column is hidden. Default isfalse.- Returns:
trueif the column is currently hidden,falseotherwise
-
setHidable
Sets whether this column can be hidden by the user. Hidable columns can be hidden and shown via the sidebar menu.- Parameters:
hidable-trueiff the column may be hidable by the user via UI interaction- Returns:
- this column
-
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
-
setResizable
Sets whether this column can be resized by the user.- Parameters:
resizable-trueif this column should be resizable,falseotherwise
-
setRenderer
Sets the renderer for this column.If a suitable converter isn't defined explicitly, the session converter factory is used to find a compatible converter.
- Parameters:
renderer- the renderer to use- Returns:
- the column itself
- Throws:
IllegalArgumentException- if no compatible converter could be found- See Also:
-
setRenderer
Sets the V7 renderer for this column.If a suitable converter isn't defined explicitly, the session converter factory is used to find a compatible converter.
- Parameters:
renderer- the renderer to use- Returns:
- the column itself
- Throws:
IllegalArgumentException- if no compatible converter could be found- See Also:
-
setRenderer
public <T> FGrid.Column setRenderer(FGrid.AbstractRenderer<?> 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.- Parameters:
renderer- V7 renderer to use, cannot be nullconverter- the converter to use- Returns:
- the column itself
- Throws:
IllegalArgumentException- if the renderer is already associated with a grid column
-
setRenderer
public <T> FGrid.Column setRenderer(com.vaadin.flow.data.renderer.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.- Parameters:
renderer- the renderer to use, cannot be nullconverter- the converter to use- Returns:
- the column itself
- Throws:
IllegalArgumentException- if the renderer is already associated with a grid column
-
setConverter
Sets the converter used to convert from the property value type to the renderer presentation type.- Parameters:
converter- the converter to use, ornullto not use any converters- Returns:
- the column itself
- Throws:
IllegalArgumentException- if the types are not compatible
-
getRenderer
public com.vaadin.flow.data.renderer.Renderer<?> getRenderer()Returns the renderer instance used by this column.- Returns:
- the renderer
-
getConverter
Returns the converter instance used by this column.- Returns:
- the converter
-
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
-
checkColumnIsAttached
Checks if column is attached and throws anIllegalStateExceptionif it is not- Throws:
IllegalStateException- if the column is no longer attached to any grid
-
equals
-
hashCode
public int hashCode()
-