Class ListGridColumn
java.lang.Object
com.jbstrap.ui.components.listgrid.ListGridColumn
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 Summary
-
Constructor Summary
ConstructorDescriptionListGridColumn
(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.ListGridColumn
(String name, ListGridColumnType type) Creates a column with the specified name and type. -
Method Summary
Modifier and TypeMethodDescriptionfinal ListGridColumnAlignment
Gets column data alignment.final DataDescriptorColumn
Gets the DataDescriptor column used to build the column.Gets data provider column nameGets column data typeprotected FormItem<?,
?> final ListGridCellFormatter
Gets the column’s formatter class.protected ListGrid
getGrid()
protected String
final String
getName()
Gets the name of the column.final ListGridCellRenderer
Gets the column renderer.getTitle()
Gets column header text.final ListGridColumnType
getType()
Gets column type.final String
getWidth()
Gets column width.boolean
boolean
Determines if the column can be filtered by rangeboolean
boolean
boolean
Sets column visibility.boolean
Sets column visibility.final ListGridColumn
Sets column data alignment.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.final ListGridColumn
setFormatter
(ListGridCellFormatter formatter) Sets the column formatter class.setMovable
(boolean movable) protected ListGridColumn
setParentGrid
(ListGrid grid) 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.final ListGridColumn
setRenderer
(ListGridCellRenderer renderer) Sets the column renderer.setResizable
(boolean resizable) setSortable
(boolean sortable) Set column header.final ListGridColumn
setType
(ListGridColumnType type) Sets column type.protected ListGridColumn
setVisible
(boolean visible) final ListGridColumn
Sets column width.setWordWrap
(boolean wrap) Sets the text wrap option.
-
Field Details
-
DISPLAYED_COLUMN_TYPES
-
-
Constructor Details
-
ListGridColumn
Creates a column with the specified name and type.- Parameters:
name
- Unique column nametype
- Column type Available types are listed in the enumListGridColumnType
.- Throws:
NullPointerException
- Thrown if the specified column name or type isnull
-
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 nameDataDescriptorColumn.getTitle(String)
- List grid column header text corresponding to the DataDescriptor header textDataDescriptorColumn.getDatatype()
- The column type is determined using the DataDescriptor. DataDescriptor column type is set using the enumListGridColumnType
.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 theListGridCellFormatterCustomFormat
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 parameterJBStrapParamType.DATE_FORMAT
is used for a DATE column. The default date time format set by theJBStrapParamType.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:- "left" - Column data is aligned to the left. (
ListGridColumnAlignment.LEFT
) - "left" - Column data is center-aligned. (
ListGridColumnAlignment.CENTER
) - "right" - Column data is aligned to the right. (
ListGridColumnAlignment.RIGHT
)
- "left" - Column data is aligned to the left. (
- Parameters:
dataDescriptorColumn
- DataDescriptor column instance used to create the columnlanguage
- Language code according to which the column is created. If not specified or set tonull
, the field is created using the default language of the framework. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE
.defaultFormatter
- Default formatter class implementation for the column- Throws:
NullPointerException
- Thrown if the specified DataDescriptor column is set tonull
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 isColumnVisibleType.ONLY_EDITOR
.
-
-
Method Details
-
setDataProvider
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
Gets data provider column name- Returns:
- The data provider column name. If data provider column is not defined, return the column name
-
setVisible
-
isVisible
public boolean isVisible()Sets column visibility.- Returns:
- If
true
, the column is visible, otherwisefalse
-
getWidth
Gets column width.- Returns:
- Column width in the specified format
-
setWidth
Sets column width.- Parameters:
width
- Column width as defined in the CSS3 standard- Returns:
- List grid column
-
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
Gets column type.- Returns:
- Column type
-
setType
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 enumListGridColumnType
.- Returns:
- List grid column
- Throws:
NullPointerException
- Thrown if the specified type isnull
UnsupportedOperationException
- Thrown if the column is built using a DataDescriptor column and you want to modify its type
-
getDataType
Gets column data type- Returns:
- Column datat type
-
getAlignment
Gets column data alignment.- Returns:
- Data alignment type
-
setAlignment
Sets column data alignment.- Parameters:
align
- Data alignment type, available alignment types are listed in the enumListGridColumnAlignment
Ifnull
is set, the method does nothing.- Returns:
- List grid column
-
getName
Gets the name of the column.- Returns:
- Column name
-
getTitle
Gets column header text.- Returns:
- Column header text or
null
if there is no header for the column
-
setTitle
Set column header.- Parameters:
title
- Column header text- Returns:
- List grid column
-
setFormatter
Sets the column formatter class.- Parameters:
formatter
- An instance of the column’s formatter class- Returns:
- List grid column
- See Also:
-
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
Sets the column renderer.- Parameters:
renderer
- An instance of the column renderer- Returns:
- List grid column
- See Also:
-
getRenderer
Gets the column renderer.- Returns:
- An instance of the column renderer class or
null
if no renderer is specified for the column
-
setWordWrap
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
- Iftrue
is set, text wrap is enabled Iffalse
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 Iffalse
is set, the text is truncated on the right edge of the column.
-
setRangeFiltering
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
- Iftrue
, 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
-
setSortable
-
isSortable
public boolean isSortable() -
setResizable
-
isResizable
public boolean isResizable() -
setMovable
-
isMovable
public boolean isMovable() -
setParentGrid
-
getFilterEditor
-
getGrid
-