Class ListGridColumn

java.lang.Object
com.jbstrap.ui.components.listgrid.ListGridColumn

public class ListGridColumn extends Object

ListGrid column

Class representing a ListGrid column. This class contains all parameters and settings for a ListGrid column. The ListGrid column is not a standalone component. It is only used by the ListGrid component. The component may only be used as a POJO class in order to parameterize, handle and set columns.

Since:
4.0
Author:
JBStrap
See Also:
  • Field Details

  • Constructor Details

    • ListGridColumn

      public ListGridColumn(String name, ListGridColumnType type)
      Creates a column with the specified name and type.
      Parameters:
      name - Unique column name
      type - Column type Available types are listed in the enum ListGridColumnType.
      Throws:
      NullPointerException - Thrown if the specified column name or type is null
    • ListGridColumn

      public ListGridColumn(DataDescriptorColumn dataDescriptorColumn, String language, ListGridCellFormatter defaultFormatter)

      Creates a new list grid column based on the specified DataDescriptor with the default formatter class and language code.

      The following parameters of the specified DataDescriptor column are used:

      • DataDescriptorColumn.getColumnName() - The name of the created list grid column is the same as the DataDescriptor column name
      • DataDescriptorColumn.getTitle(String) - List grid column header text corresponding to the DataDescriptor header text
      • DataDescriptorColumn.getDatatype() - The column type is determined using the DataDescriptor. DataDescriptor column type is set using the enum ListGridColumnType.
      • MetaParamName.FORMATTER - You can specify a custom formatter using this parameter. Specify the full name of the formatter in the parameter. If the parameter is not specified, the default formatter for the column’s data type is used.
      • MetaParamName.DATE_FORMAT - This parameter specifies the displayed date format. If the column has the type DATE or DATETIME and the column’s formatter implements the ListGridCellFormatterCustomFormat interface, the format specified in the parameter is passed to the formatter. If the parameter is not specified, the default date format set in the parameter JBStrapParamType.DATE_FORMAT is used for a DATE column. The default date time format set by the JBStrapParamType.DATETIME_FORMAT parameter is used for the DATETIME column.
      • MetaParamName.WIDTH - This parameter specifies column width. Width is specified using the the CSS3 standard. If the parameter is not specified, column width is automatically calculated. All columns will have a uniform size and fit to the width of the grid. The columns will have a minimum width of 150 pixels. If there are several columns in the grid, it can be horizontally scrolled.
      • MetaParamName.ALIGN - This parameter specifies the alignment of data within the columns. If the parameter is not specified, the default data alignment type is used. You can use the parameter to provide the following values:

      Parameters:
      dataDescriptorColumn - DataDescriptor column instance used to create the column
      language - Language code according to which the column is created. If not specified or set to null, the field is created using the default language of the framework. The default language of the framework is set via the JBStrap parameter JBStrapParamType.DEFAULT_LANGUAGE.
      defaultFormatter - Default formatter class implementation for the column
      Throws:
      NullPointerException - Thrown if the specified DataDescriptor column is set to null
      IllegalArgumentException - Thrown if the visibility setting of the specified column does not allow the column to be displayed in the grid Such a visibility setting is ColumnVisibleType.ONLY_EDITOR.
  • Method Details

    • setDataProvider

      public ListGridColumn setDataProvider(String columnName)
      Set the data provider column.
      The data in the column specified here will be subject to filtering and sorting on the grid.
      Parameters:
      columnName - The data provider column name
      Returns:
      List grid column
    • getDataProvider

      public String getDataProvider()
      Gets data provider column name
      Returns:
      The data provider column name. If data provider column is not defined, return the column name
    • setVisible

      protected ListGridColumn setVisible(boolean visible)
    • isVisible

      public boolean isVisible()
      Sets column visibility.
      Returns:
      If true, the column is visible, otherwise false
    • getWidth

      public final String getWidth()
      Gets column width.
      Returns:
      Column width in the specified format
    • setWidth

      public final ListGridColumn setWidth(String width)
      Sets column width.
      Parameters:
      width - Column width as defined in the CSS3 standard
      Returns:
      List grid column
    • getDataDescriptorColumn

      public final DataDescriptorColumn getDataDescriptorColumn()
      Gets the DataDescriptor column used to build the column.
      Returns:
      DataDescriptor column instance used to build the column or null if the column was not built using a DataDescriptor
    • getType

      public final ListGridColumnType getType()
      Gets column type.
      Returns:
      Column type
    • setType

      public final ListGridColumn setType(ListGridColumnType type)
      Sets column type. If the column was built using a DataDescriptor, the method cannot be used. By modifying the column type, the column’s alignment and formatter are also modified.
      Parameters:
      type - Column type Available types are listed in the enum ListGridColumnType.
      Returns:
      List grid column
      Throws:
      NullPointerException - Thrown if the specified type is null
      UnsupportedOperationException - Thrown if the column is built using a DataDescriptor column and you want to modify its type
    • getDataType

      public DataDescriptorColumnDatatype getDataType()
      Gets column data type
      Returns:
      Column datat type
    • getAlignment

      public final ListGridColumnAlignment getAlignment()
      Gets column data alignment.
      Returns:
      Data alignment type
    • setAlignment

      public final ListGridColumn setAlignment(ListGridColumnAlignment align)
      Sets column data alignment.
      Parameters:
      align - Data alignment type, available alignment types are listed in the enum ListGridColumnAlignment If null is set, the method does nothing.
      Returns:
      List grid column
    • getName

      public final String getName()
      Gets the name of the column.
      Returns:
      Column name
    • getTitle

      public String getTitle()
      Gets column header text.
      Returns:
      Column header text or null if there is no header for the column
    • setTitle

      public ListGridColumn setTitle(String title)
      Set column header.
      Parameters:
      title - Column header text
      Returns:
      List grid column
    • setFormatter

      public final ListGridColumn setFormatter(ListGridCellFormatter formatter)
      Sets the column formatter class.
      Parameters:
      formatter - An instance of the column’s formatter class
      Returns:
      List grid column
      See Also:
    • getFormatter

      public final ListGridCellFormatter getFormatter()
      Gets the column’s formatter class.
      Returns:
      An instance of the column formatter or null if no formatter is specified for the column
    • setRenderer

      public final ListGridColumn setRenderer(ListGridCellRenderer renderer)
      Sets the column renderer.
      Parameters:
      renderer - An instance of the column renderer
      Returns:
      List grid column
      See Also:
    • getRenderer

      public final ListGridCellRenderer getRenderer()
      Gets the column renderer.
      Returns:
      An instance of the column renderer class or null if no renderer is specified for the column
    • setWordWrap

      public ListGridColumn setWordWrap(boolean wrap)
      Sets the text wrap option. By default, text wrap causes the text to b displayed in several lines if it does not fit into the column.
      Parameters:
      wrap - If true is set, text wrap is enabled If false is set, the text is truncated on the right edge of the column.
      Returns:
      List grid column
    • isWordWrap

      public boolean isWordWrap()
      Sets column visibility.
      Returns:
      If true is set, the text is displayed wrapped in multiple lines If false is set, the text is truncated on the right edge of the column.
    • setRangeFiltering

      public ListGridColumn setRangeFiltering(boolean rangeFiltering)
      Sets if the data in the column, when used in the adaptive filter, are for a discrete value, or for a range. This setting is only applicable with date and numeric columns, and by default these columns can be filtered by range.
      Parameters:
      rangeFiltering - If true, the column can be filtered by range. Otherwise, it can be be filtered by a discrete value
      Returns:
      The list grid column
    • isRangeFiltering

      public boolean isRangeFiltering()
      Determines if the column can be filtered by range
      Returns:
      If true, the column can be filtered by range. Otherwise, it can be be filtered by a discrete value
    • getJsonParams

      protected String getJsonParams()
    • setSortable

      public ListGridColumn setSortable(boolean sortable)
    • isSortable

      public boolean isSortable()
    • setResizable

      public ListGridColumn setResizable(boolean resizable)
    • isResizable

      public boolean isResizable()
    • setMovable

      public ListGridColumn setMovable(boolean movable)
    • isMovable

      public boolean isMovable()
    • setParentGrid

      protected ListGridColumn setParentGrid(ListGrid grid)
    • getFilterEditor

      protected FormItem<?,?> getFilterEditor()
    • getGrid

      protected ListGrid getGrid()