com.vaadin.client.widgets
Class Grid.Column<C,T>

java.lang.Object
  extended by com.vaadin.client.widgets.Grid.Column<C,T>
Type Parameters:
C - the column type
T - the row type
Direct Known Subclasses:
Grid.SelectionColumn
Enclosing class:
Grid<T>

public abstract static class Grid.Column<C,T>
extends java.lang.Object

Base class for grid columns internally used by the Grid. The user should use Grid.SelectionColumn when creating new columns.


Constructor Summary
Grid.Column()
          Constructs a new column with a simple TextRenderer.
Grid.Column(Renderer<? super C> renderer)
          Constructs a new column with a custom renderer.
Grid.Column(java.lang.String caption)
          Constructs a new column with a simple TextRenderer.
Grid.Column(java.lang.String caption, Renderer<? super C> renderer)
          Constructs a new column with a custom renderer.
 
Method Summary
 Grid.Column<C,T> clearExpandRatio()
          Clears the column's expand ratio.
 int getExpandRatio()
          Gets the expand ratio 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 isSortable()
          Are sort indicators shown for the column.
 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(java.lang.String caption)
          Sets a header 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> setSortable(boolean sortable)
          Enables sort indicators for the grid.
 Grid.Column<C,T> setWidth(double pixels)
          Sets the pixel width of the column.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Grid.Column

public Grid.Column()
Constructs a new column with a simple TextRenderer.


Grid.Column

public Grid.Column(java.lang.String caption)
            throws java.lang.IllegalArgumentException
Constructs a new column with a simple TextRenderer.

Parameters:
caption - The header caption for this column
Throws:
java.lang.IllegalArgumentException - if given header caption is null

Grid.Column

public Grid.Column(Renderer<? super C> renderer)
            throws java.lang.IllegalArgumentException
Constructs a new column with a custom renderer.

Parameters:
renderer - The renderer to use for rendering the cells
Throws:
java.lang.IllegalArgumentException - if given Renderer is null

Grid.Column

public Grid.Column(java.lang.String caption,
                   Renderer<? super C> renderer)
            throws java.lang.IllegalArgumentException
Constructs a new column with a custom renderer.

Parameters:
renderer - The renderer to use for rendering the cells
caption - The header caption for this column
Throws:
java.lang.IllegalArgumentException - if given Renderer or header caption is null
Method Detail

setHeaderCaption

public Grid.Column<C,T> setHeaderCaption(java.lang.String caption)
Sets a header caption for this column.

Parameters:
caption - The header caption for this column
Returns:
the column itself
Throws:
java.lang.IllegalArgumentException - if given caption text is null

getValue

public abstract C getValue(T row)
Returns the data that should be rendered into the cell. By default returning Strings and Widgets are supported. If the return type is a String then it will be treated as preformatted text.

To support other types you will need to pass a custom renderer to the column via the column constructor.

Parameters:
row - The row object that provides the cell content.
Returns:
The cell content

getRenderer

public Renderer<? super C> getRenderer()
The renderer to render the cell with. By default renders the data as a String or adds the widget into the cell if the column type is of widget type.

Returns:
The renderer to render the cell content with

setRenderer

public Grid.Column<C,T> setRenderer(Renderer<? super C> renderer)
                             throws java.lang.IllegalArgumentException
Sets a custom Renderer for this column.

Parameters:
renderer - The renderer to use for rendering the cells
Returns:
the column itself
Throws:
java.lang.IllegalArgumentException - if given Renderer is null

setWidth

public Grid.Column<C,T> setWidth(double pixels)
Sets the pixel width of the column. Use a negative value for the grid to autosize column based on content and available space.

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.

Parameters:
pixels - the width in pixels or negative for auto sizing

getWidth

public double getWidth()
Returns the pixel width of the column as given by the user.

Note: If a negative value was given to setWidth(double), that same negative value is returned here.

Returns:
pixel width of the column, or a negative number if the column width has been automatically calculated.
See Also:
setWidth(double), getWidthActual()

getWidthActual

public double getWidthActual()
Returns the effective pixel width of the column.

This differs from getWidth() only when the column has been automatically resized.

Returns:
pixel width of the column.

setSortable

public Grid.Column<C,T> setSortable(boolean sortable)
Enables sort indicators for the grid.

Note:The API can still sort the column even if this is set to false.

Parameters:
sortable - true when column sort indicators are visible.
Returns:
the column itself

isSortable

public boolean isSortable()
Are sort indicators shown for the column.

Returns:
true if the column is sortable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setMinimumWidth

public Grid.Column<C,T> setMinimumWidth(double pixels)
Sets the minimum width for this column.

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.

Parameters:
pixels - the minimum width
Returns:
this column

setMaximumWidth

public Grid.Column<C,T> 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.

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.

Parameters:
pixels - the maximum width
immediately - 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).
Returns:
this column

setExpandRatio

public Grid.Column<C,T> setExpandRatio(int ratio)
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, 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.

Parameters:
expandRatio - the expand ratio of this column. 0 to not have it expand at all. A negative number to clear the expand value.
Returns:
this column

clearExpandRatio

public Grid.Column<C,T> clearExpandRatio()
Clears the column's expand ratio.

Same as calling setExpandRatio(-1)

Returns:
this column

getMinimumWidth

public double getMinimumWidth()
Gets the minimum width for this column.

Returns:
the minimum width for this column
See Also:
setMinimumWidth(double)

getMaximumWidth

public double getMaximumWidth()
Gets the maximum width for this column.

Returns:
the maximum width for this column
See Also:
setMaximumWidth(double)

getExpandRatio

public int getExpandRatio()
Gets the expand ratio for this column.

Returns:
the expand ratio for this column
See Also:
setExpandRatio(int)

setEditable

public 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. By default columns are editable.

Parameters:
editable - true to set this column editable, false otherwise
Returns:
this column
Throws:
java.lang.IllegalStateException - if the editor is currently active
See Also:
Grid.editRow(int), Grid.isEditorActive()

isEditable

public boolean isEditable()
Returns whether the values in this column are editable by the user when the row editor is active.

Returns:
true if this column is editable, false otherwise
See Also:
setEditable(boolean)


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.