Class AbstractColumn<M,​I,​S>

    • Constructor Detail

      • AbstractColumn

        public AbstractColumn​(String columnId,
                              IModel<String> headerModel,
                              S sortProperty)
        Creates instance with specified column id, header model and sort property.
        Parameters:
        columnId - column identifier - must be unique within the grid
        headerModel - model for column title
        sortProperty - optional string that will be returned by ISortState to indicate that the column is being sorted
      • AbstractColumn

        public AbstractColumn​(String columnId,
                              IModel<String> headerModel)
        Creates instance with specified column id and header model
        Parameters:
        columnId - column identifier - must be unique within the grid
        headerModel - model for column title
    • Method Detail

      • setHeaderTooltipModel

        public AbstractColumn<M,​I,​S> setHeaderTooltipModel​(IModel<String> headerTooltipModel)
        Sets the model for header tooltip.
        Parameters:
        headerTooltipModel - model for header tooltip
        Returns:
        this (useful for method chaining)
      • getHeaderTooltipModel

        public IModel<String> getHeaderTooltipModel()
        Returns the model for header tooltip
        Returns:
        model for header tooltip
      • getHeaderModel

        public IModel<String> getHeaderModel()
        Returns the model for header (caption)
        Returns:
        header 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>
        Parameters:
        rowModel - model for given row
        rowNum - index of row for DataGrid, -1 for TreeGrid
        Returns:
        cell style class or null
      • getColSpan

        public 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.
        Specified by:
        getColSpan in interface IGridColumn<M,​I,​S>
        Parameters:
        rowModel - model for given row
        Returns:
        colspan value
      • getHeaderCssClass

        public String getHeaderCssClass()
        Returns the CSS class for this column header. The class is applied to the appropriate <th> element in the grid.
        Specified by:
        getHeaderCssClass in interface IGridColumn<M,​I,​S>
        Returns:
        CSS class for this column header or null
      • getId

        public 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.
        Specified by:
        getId in interface IGridColumn<M,​I,​S>
        Returns:
        column identifier
      • setInitialSize

        public AbstractColumn<M,​I,​S> setInitialSize​(int initialSize)
        Sets the initial size for this column. The unit depends on setSizeUnit(SizeUnit). By default the unit is pixels.
        Parameters:
        initialSize - initial size of the column
        Returns:
        this (useful for method chaining)
      • setSizeUnit

        public AbstractColumn<M,​I,​S> setSizeUnit​(SizeUnit sizeUnit)
        Sets the size unit for this column. The default size unit is SizeUnit.PX.
        Parameters:
        sizeUnit -
        Returns:
        this (useful for method chaining)
      • getSizeUnit

        public SizeUnit getSizeUnit()
        Returns the unit in which sizes are specified. If the column is resizable, this method must always return SizeUnit.PX.
        Specified by:
        getSizeUnit in interface IGridColumn<M,​I,​S>
        Returns:
        size unit
      • setMaxSize

        public AbstractColumn<M,​I,​S> setMaxSize​(int maxSize)
        Sets the maximal size of this column. Only relevant if the column is resizable and the column unit is SizeUnit.PX (pixels).
        Parameters:
        maxSize - maximal column size
        Returns:
        this (useful for method chaining)
      • getMaxSize

        public int getMaxSize()
        Returns the maximal size of resizable column. Return values not greater than zero will be ignored.
        Specified by:
        getMaxSize in interface IGridColumn<M,​I,​S>
        Returns:
        maximal size
      • setMinSize

        public AbstractColumn<M,​I,​S> setMinSize​(int minSize)
        Sets the minimal size of this column. Only relevant if the column is resizable and the column unit is SizeUnit.PX (pixels).
        Parameters:
        minSize - minimal column size
        Returns:
        this (useful for method chaining)
      • getMinSize

        public int getMinSize()
        Returns the minimal size of resizable column. Return values not greater than zero will be ignored.
        Specified by:
        getMinSize in interface IGridColumn<M,​I,​S>
        Returns:
        minimal size
      • getSortProperty

        public S 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.
        Specified by:
        getSortProperty in interface IGridColumn<M,​I,​S>
        Returns:
        sort property or null if the column is not sortable
        See Also:
        IGridSortState.ISortStateColumn.getPropertyName()
      • setReorderable

        public AbstractColumn<M,​I,​S> setReorderable​(boolean reorderable)
        Sets whether the user will be able to drag and reorder this column (true by default).
        Parameters:
        reorderable - true if the column will be reorderable, false otherwise
        Returns:
        this (useful for method chaining)
      • setResizable

        public AbstractColumn<M,​I,​S> setResizable​(boolean resizable)
        Sets whether the user will be able to resize this column (true by default). In order for the column to be resizable, the size unit must be SizeUnit.PX.
        Parameters:
        resizable - true if the column will be resizable, false otherwise
        Returns:
        this (useful for method chaining)
        See Also:
        setSizeUnit(SizeUnit)
      • isLightWeight

        public 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
        Specified by:
        isLightWeight in interface IGridColumn<M,​I,​S>
        Parameters:
        rowModel - model for given row
        Returns:
        true if the cell is lightweight, false otherwise
      • newCell

        public abstract 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>
        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>
        Parameters:
        componentId - required id that the component must have
        Returns:
        Component representing a column header
      • setGrid

        public void setGrid​(AbstractGrid<M,​I,​S> grid)
        Invoked before the first render of the grid. Column that need grid reference can implement this method and store the reference.
        Specified by:
        setGrid in interface IGridColumn<M,​I,​S>
        Parameters:
        grid - grid that contains this column
      • getGrid

        public AbstractGrid<M,​I,​S> getGrid()
        Returns the grid instance associated with this column.
        Returns:
        grid instance
      • setWrapText

        public AbstractColumn<M,​I,​S> setWrapText​(boolean wrapText)
        Sets whether the text in column will be wrapped when it is too long to fit the column ( false by default).
        Parameters:
        wrapText - true if the text will be wrapped, false otherwise.
        Returns:
        this (useful for method chaining)
      • getWrapText

        public 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.
        Specified by:
        getWrapText in interface IGridColumn<M,​I,​S>
        Returns:
        whether this colulmn's text should wrap or not
      • cellClicked

        public 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.
        Specified by:
        cellClicked in interface IGridColumn<M,​I,​S>
        Parameters:
        rowModel - Model for clicked row
        Returns:
        true if the default behavior when row is clicked should be supressed, false otherwise.