Class CheckBoxColumn<M,​I,​S>

  • Type Parameters:
    M - grid model object type
    I - row/item model object type
    All Implemented Interfaces:
    IGridColumn<M,​I,​S>, Serializable, IDetachable, IClusterable

    public class CheckBoxColumn<M,​I,​S>
    extends AbstractColumn<M,​I,​S>
    Column that allows a row in grid to be selected. The column cell contains a checkbox which selects and deselects the row. When row selection state is changed, the entire row is updated using Ajax.

    If the grid is in single selection mode, the column header will remain empty. If the column is in multi selection mode, the column header will contain a checkbox which selects all displayed rows (i.e. the rows on current page for DataGrid and visible rows in TreeGrid). When the header checkbox is deselected, it deselects all rows (on all pages). This is to ensure that when user deselects one page, no invisible rows are left selected.

    Author:
    Matej Knopp
    See Also:
    Serialized Form
    • Constructor Detail

      • CheckBoxColumn

        public CheckBoxColumn​(String columnId)
        Creates a new checkbox column.
        Parameters:
        columnId - column id (must be unique within the grid)
    • Method Detail

      • newCell

        public Component newCell​(WebMarkupContainer parent,
                                 String componentId,
                                 IModel<I> rowModel)
        Creates a new cell component. This method is called for rows that are not lightweight ( IGridColumn.isLightWeight(IModel) returns false ).
        Specified by:
        newCell in interface IGridColumn<M,​I,​S>
        Specified by:
        newCell in class AbstractColumn<M,​I,​S>
        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
      • newHeader

        public Component newHeader​(String componentId)
        Creates a new component for column header.
        Specified by:
        newHeader in interface IGridColumn<M,​I,​S>
        Overrides:
        newHeader in class AbstractColumn<M,​I,​S>
        Parameters:
        componentId - required id that the component must have
        Returns:
        Component representing a column header
      • isCheckBoxEnabled

        protected boolean isCheckBoxEnabled​(IModel<I> model)
      • isCheckBoxVisible

        protected boolean isCheckBoxVisible​(IModel<I> model)
      • getCellCssClass

        public 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.
        Specified by:
        getCellCssClass in interface IGridColumn<M,​I,​S>
        Overrides:
        getCellCssClass in class AbstractColumn<M,​I,​S>
        Parameters:
        rowModel - model for given row
        rowNum - index of row for DataGrid, -1 for TreeGrid
        Returns:
        cell style class or null
      • getRowTooltipModel

        protected IModel<String> getRowTooltipModel​(IModel<I> itemModel)
        Overriding this method allows to specify a tooltip for checkbox in each row.
        Parameters:
        itemModel - model for item in given row
        Returns:
        tooltip model or null