C
- the column typeT
- the row typepublic abstract static class Grid.Column<C,T> extends Object
Grid.Column
when creating new columns.Modifier and Type | Field and Description |
---|---|
protected boolean |
editable
The editable state of this column.
|
protected int |
expandRatio
The expand ratio of this column.
|
protected String |
headerCaption
The header-caption of this column.
|
protected boolean |
hidable
The hidable state of this column.
|
protected boolean |
hidden
The hidden state of this column.
|
protected String |
hidingToggleCaption
The hiding-toggle-caption of this column.
|
protected double |
maximumWidthPx
The maximum width in pixels of this column.
|
protected double |
minimumWidthPx
The minimum width in pixels of this column.
|
protected boolean |
resizable
The resizable state of this column.
|
protected boolean |
sortable
The sortable state of this column.
|
protected double |
widthUser
Width of column in pixels as
setWidth(double) has been called. |
Constructor and Description |
---|
Column()
Constructs a new column with a simple TextRenderer.
|
Column(Renderer<? super C> renderer)
Constructs a new column with a custom renderer.
|
Column(String caption)
Constructs a new column with a simple TextRenderer.
|
Column(String caption,
Renderer<? super C> renderer)
Constructs a new column with a custom renderer.
|
Modifier and Type | Method and Description |
---|---|
Grid.Column<C,T> |
clearExpandRatio()
Clears the column's expand ratio.
|
int |
getExpandRatio()
Gets the expand ratio for this column.
|
String |
getHeaderCaption()
Returns the current header caption for this column
|
String |
getHidingToggleCaption()
Gets the hiding toggle caption for this column.
|
double |
getMaximumWidth()
Gets the maximum width for this column.
|
double |
getMinimumWidth()
Gets the minimum width for this column.
|
Renderer<? super C> |
getRenderer()
The renderer to render the cell with.
|
abstract C |
getValue(T row)
Returns the data that should be rendered into the cell.
|
double |
getWidth()
Returns the pixel width of the column as given by the user.
|
double |
getWidthActual()
Returns the effective pixel width of the column.
|
boolean |
isEditable()
Returns whether the values in this column are editable by the user
when the row editor is active.
|
boolean |
isHidable()
Is it possible for the the user to hide this column.
|
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.
|
protected void |
setDefaultHeaderContent(Grid.HeaderCell cell)
Resets the default header cell contents to column header captions.
|
Grid.Column<C,T> |
setEditable(boolean editable)
Sets whether the values in this column should be editable by the user
when the row editor is active.
|
Grid.Column<C,T> |
setExpandRatio(int ratio)
Sets the ratio with which the column expands.
|
Grid.Column<C,T> |
setHeaderCaption(String caption)
Sets a header caption for this column.
|
Grid.Column<C,T> |
setHidable(boolean hidable)
Set whether it is possible for the user to hide this column or not.
|
Grid.Column<C,T> |
setHidden(boolean hidden)
Hides or shows the column.
|
Grid.Column<C,T> |
setHidingToggleCaption(String hidingToggleCaption)
Sets the hiding toggle's caption for this column.
|
Grid.Column<C,T> |
setMaximumWidth(double pixels)
Sets the maximum width for this column.
|
Grid.Column<C,T> |
setMinimumWidth(double pixels)
Sets the minimum width for this column.
|
Grid.Column<C,T> |
setRenderer(Renderer<? super C> renderer)
Sets a custom
Renderer for this column. |
Grid.Column<C,T> |
setResizable(boolean resizable)
Sets whether this column can be resized by the user.
|
Grid.Column<C,T> |
setSortable(boolean sortable)
Sets whether the column should be sortable by the user.
|
Grid.Column<C,T> |
setWidth(double pixels)
Sets the pixel width of the column.
|
String |
toString() |
protected double widthUser
setWidth(double)
has been called.protected boolean sortable
protected boolean editable
protected boolean resizable
protected boolean hidden
protected boolean hidable
protected String headerCaption
protected String hidingToggleCaption
protected double minimumWidthPx
protected double maximumWidthPx
protected int expandRatio
public Column()
public Column(String caption) throws IllegalArgumentException
caption
- The header caption for this columnIllegalArgumentException
- if given header caption is nullpublic Column(Renderer<? super C> renderer) throws IllegalArgumentException
renderer
- The renderer to use for rendering the cellsIllegalArgumentException
- if given Renderer is nullpublic Column(String caption, Renderer<? super C> renderer) throws IllegalArgumentException
renderer
- The renderer to use for rendering the cellscaption
- The header caption for this columnIllegalArgumentException
- if given Renderer or header caption is nullpublic Grid.Column<C,T> setHeaderCaption(String caption)
caption
- The header caption for this columnpublic String getHeaderCaption()
public abstract C getValue(T row)
To support other types you will need to pass a custom renderer to the column via the column constructor.
row
- The row object that provides the cell content.public Renderer<? super C> getRenderer()
public Grid.Column<C,T> setRenderer(Renderer<? super C> renderer) throws IllegalArgumentException
Renderer
for this column.renderer
- The renderer to use for rendering the cellsIllegalArgumentException
- if given Renderer is nullpublic Grid.Column<C,T> setWidth(double pixels)
This action is done "finally", once the current execution loop returns. This is done to reduce overhead of unintentionally always recalculate all columns, when modifying several columns at once.
If the column is currently hidden
, then this set
width has effect only once the column has been made visible again.
pixels
- the width in pixels or negative for auto sizingpublic double getWidth()
Note: If a negative value was given to
setWidth(double)
, that same negative value is returned here.
Note: Returns the value, even if the column is currently
hidden
.
setWidth(double)
,
getWidthActual()
public double getWidthActual()
This differs from getWidth()
only when the column has been
automatically resized, or when the column is currently
hidden
, when the value is 0.
public Grid.Column<C,T> setSortable(boolean sortable)
sortable
- true
if the user should be able to sort the
column, false
otherwisepublic 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<C,T> 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
otherwisepublic Grid.Column<C,T> 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<C,T> setHidable(boolean hidable)
false
.
Note: it is still possible to hide the column
programmatically using setHidden(boolean)
.
hidable
- true
the user can hide this column, false
otherwisepublic 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<C,T> setHidingToggleCaption(String hidingToggleCaption)
hidable
.
The default value is null
. In this case the header
caption is used, see setHeaderCaption(String)
.
hidingToggleCaption
- the caption for the hiding toggle for this columnpublic String getHidingToggleCaption()
setHidingToggleCaption(String)
public Grid.Column<C,T> setMinimumWidth(double pixels)
This defines the minimum guaranteed pixel width of the column when it is set to expand.
This action is done "finally", once the current execution loop returns. This is done to reduce overhead of unintentionally always recalculate all columns, when modifying several columns at once.
pixels
- the minimum widthpublic Grid.Column<C,T> setMaximumWidth(double pixels)
This defines the maximum allowed pixel width of the column when it is set to expand.
This action is done "finally", once the current execution loop returns. This is done to reduce overhead of unintentionally always recalculate all columns, when modifying several columns at once.
pixels
- the maximum widthimmediately
- true
if the widths should be executed
immediately (ignoring lazy loading completely), or
false
if the command should be run after a
while (duplicate non-immediately invocations are ignored).public Grid.Column<C,T> setExpandRatio(int ratio)
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, bceause we have 3 parts total, and this column reservs 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.
This action is done "finally", once the current execution loop returns. This is done to reduce overhead of unintentionally always recalculate all columns, when modifying several columns at once.
expandRatio
- the expand ratio of this column. 0
to not have it
expand at all. A negative number to clear the expand
value.public Grid.Column<C,T> clearExpandRatio()
Same as calling setExpandRatio(-1)
public double getMinimumWidth()
setMinimumWidth(double)
public double getMaximumWidth()
setMaximumWidth(double)
public int getExpandRatio()
setExpandRatio(int)
public Grid.Column<C,T> setEditable(boolean editable)
editable
- true
to set this column editable, false
otherwiseIllegalStateException
- if the editor is currently activeGrid.editRow(int)
,
Grid.isEditorActive()
public boolean isEditable()
true
if this column is editable, false
otherwisesetEditable(boolean)
protected void setDefaultHeaderContent(Grid.HeaderCell cell)
cell
- default header cell for this columnCopyright © 2019 Vaadin Ltd. All rights reserved.