com.inmethod.grid
Interface IGridColumn<M,I>

Type Parameters:
M - grid model object type
I - row/item model object type
All Superinterfaces:
IClusterable, IDetachable, Serializable
All Known Implementing Classes:
AbstractColumn, AbstractLightWeightColumn, AbstractTreeColumn, AddDeleteColumn, BaseTreeColumn, CheckBoxColumn, CheckBoxPropertyColumn, DatePropertyColumn, DropDownChoiceColumn, EditablePropertyColumn, EditablePropertyTreeColumn, LinkColumn, PageLinkColumn, PropertyColumn, PropertyTreeColumn, SubmitCancelColumn, WicketColumnAdapter

public interface IGridColumn<M,I>
extends IDetachable

Represents a column in a DataGrid or a TreeGrid.

Author:
Matej Knopp

Method Summary
 boolean cellClicked(IModel<I> rowModel)
          Allows to override default behavior when a row is clicked.
 String getCellCssClass(IModel<I> rowModel, int rowNum)
          Returns the cell specified by rowModel.
 int getColSpan(IModel<I> rowModel)
          Returns the spanning value for cell specified by rowModel.
 String getHeaderCssClass()
          Returns the CSS class for this column header.
 String getId()
          Returns the column id.
 int getInitialSize()
          Returns the initial size of column.
 int getMaxSize()
          Returns the maximal size of resizable column.
 int getMinSize()
          Returns the minimal size of resizable column.
 SizeUnit getSizeUnit()
          Returns the unit in which sizes are specified.
 String getSortProperty()
          Result of this method determines whether the column is sortable and in case it is, also determines the sort property.
 boolean getWrapText()
          Determines the behavior when there is more text in cell than it fits in it.
 boolean isLightWeight(IModel<I> rowModel)
          Returns whether this column is uses a component for cell in given row (not lightweight) or an IRenderable implementation.
 boolean isReorderable()
          Returns whether user will be allowed to reorder this column (i.e.
 boolean isResizable()
          Returns whether user will be able to resize this column.
 IRenderable<I> newCell(IModel<I> rowModel)
          Creates a new IRenderable instance that is used to render to render the output of cell for given row.
 Component newCell(WebMarkupContainer parent, String componentId, IModel<I> rowModel)
          Creates a new cell component.
 Component newHeader(String componentId)
          Creates a new component for column header.
 void setGrid(AbstractGrid<M,I> grid)
          Invoked before the first render of the grid.
 
Methods inherited from interface org.apache.wicket.model.IDetachable
detach
 

Method Detail

getId

String getId()
Returns the column id. Each column must have a unique Id. The only allowed characters in a column id are alphanumeric characters, dash, dot and underscore.

Returns:
column identifier

newHeader

Component newHeader(String componentId)
Creates a new component for column header.

Parameters:
componentId - required id that the component must have
Returns:
Component representing a column header

isLightWeight

boolean isLightWeight(IModel<I> rowModel)
Returns whether this column is uses a component for cell in given row (not lightweight) or an IRenderable implementation. Generally, if the cell is non-interactive (label only), it's better to use an IRenderable implementation, as it has zero memory footprint

Parameters:
rowModel - model for given row
Returns:
true if the cell is lightweight, false otherwise

newCell

Component newCell(WebMarkupContainer parent,
                  String componentId,
                  IModel<I> rowModel)
Creates a new cell component. This method is called for rows that are not lightweight ( isLightWeight(IModel) returns false ).

Parameters:
parent - Parent component. This is passed in only for convenience, the method implementation is not supposed to add the newly created component to the parent.
componentId - required id of newly created components
rowModel - model for given row
Returns:
new cell component

newCell

IRenderable<I> newCell(IModel<I> rowModel)
Creates a new IRenderable instance that is used to render to render the output of cell for given row. This method is called for rows that are lightweight ( isLightWeight(IModel) returns true ).

Parameters:
rowModel - model for given row
Returns:
IRenderable instance

getSortProperty

String getSortProperty()
Result of this method determines whether the column is sortable and in case it is, also determines the sort property. If the column is sortable and user sorts by it, the sort property can then be obtained through IGridSortState.

Returns:
sort property or null if the column is not sortable
See Also:
IGridSortState.ISortStateColumn.getPropertyName()

isResizable

boolean isResizable()
Returns whether user will be able to resize this column. If the column is resizable, getSizeUnit() must return SizeUnit.PX, otherwise an IllegalStateException will be thrown.

Returns:
true if the column is resizable, false otherwise.

getInitialSize

int getInitialSize()
Returns the initial size of column. The unit is determined by getSizeUnit().

Returns:
initial column size

getSizeUnit

SizeUnit getSizeUnit()
Returns the unit in which sizes are specified. If the column is resizable, this method must always return SizeUnit.PX.

Returns:
size unit

getMinSize

int getMinSize()
Returns the minimal size of resizable column. Return values not greater than zero will be ignored.

Returns:
minimal size

getMaxSize

int getMaxSize()
Returns the maximal size of resizable column. Return values not greater than zero will be ignored.

Returns:
maximal size

isReorderable

boolean isReorderable()
Returns whether user will be allowed to reorder this column (i.e. change column position relative to other columns).

Returns:
true if the column is reorderable, false otherwise

getHeaderCssClass

String getHeaderCssClass()
Returns the CSS class for this column header. The class is applied to the appropriate <th> element in the grid.

Returns:
CSS class for this column header or null

getCellCssClass

String getCellCssClass(IModel<I> rowModel,
                       int rowNum)
Returns the cell specified by rowModel. The class is applied to the appropriate <td> element in the grid.

Parameters:
rowModel - model for given row
rowNum - index of row for DataGrid, -1 for TreeGrid
Returns:
cell style class or null

getColSpan

int getColSpan(IModel<I> rowModel)
Returns the spanning value for cell specified by rowModel. The cell can span over certain number of adjacent cells. The value determines how many cell will this column take. Values less than 2 mean that no extra spanning will be done.

Parameters:
rowModel - model for given row
Returns:
colspan value

setGrid

void setGrid(AbstractGrid<M,I> grid)
Invoked before the first render of the grid. Column that need grid reference can implement this method and store the reference.

Parameters:
grid - grid that contains this column

getWrapText

boolean getWrapText()
Determines the behavior when there is more text in cell than it fits in it. If the method returns true, the text will be wrapped and row height increased. If the method returns false, the remaining part of text will be hidden.

Returns:
whether this colulmn's text should wrap or not

cellClicked

boolean cellClicked(IModel<I> rowModel)
Allows to override default behavior when a row is clicked. Depending on grid settings the default behavior can select the item. If this method returns true the default behavior will be suppressed.

Parameters:
rowModel - Model for clicked row
Returns:
true if the default behavior when row is clicked should be supressed, false otherwise.


Copyright © 2007-2012 inMethod s.r.o.. All Rights Reserved.