Class ListGrid
- All Implemented Interfaces:
Animatable<ListGrid>
,CanDrop<ListGrid>
,FilterBarFiltering<ListGrid>
,Draggable<ListGrid>
,Fetchable<ListGrid>
,HandleHotKey<ListGrid>
,BasedOnDataDescriptor<ListGrid>
,Exportable<Fetchable<ListGrid>>
,Filterable<ListGrid>
ListGrid component
The ListGrid visualizes data in a grid format.
The component is a data visualization component and cannot be used to modify data.
Data values are displayed in cells as defined by column settings.
The component enables you to format data by using the ListGridCellFormatter
.
Moreover, you can also specify a custom renderer.
The rendered component is displayed in the cell.
The rendered component can be either a compound one or a container.
This enables you to add several components to the cell.
In order to use the renderer, you must implement the ListGridCellRenderer
interface.
Formatter or renderer classes are passed to the specific column by calling the ListGridColumn.setRenderer(ListGridCellRenderer)
and ListGridColumn.setFormatter(ListGridCellFormatter)
methods.
The component can be built using a DataDescriptor. Column parameterization is done using the DataDescriptor. The component automatically creates and sets the necessary columns; queries and displays data in the grid.
Displayed data can be sorted by clicking on the grid header. If yes, specify if the sort is done using a single column or multiple columns.
The component enables you to filter data.
There are two types of filter: default filter and custom filter.
The default one is implemented from code. It is always valid.
The user is not allowed to modify the default filter.
You can also specify a custom filter for the component.
If a filter component is displayed, the user is able to set filter criteria.
Custom filter criteria are joined to the default filter criteria with an AND operator.
The component supports the use of SimpleFilter
, TextFilter
, AdvancedFilter
and AdaptiveFilter
.
You can also use a custom filter implementation.
Use the method setFilterType(FilterType)
to set if the filter is displayed.
The component supports inserting new records, or modifying and deleting previous records. Modifications are saved to the database within a single transaction. Concurrent modifications are only committed to the database if all of them are successful.
The user is allowed to modify column width and order, hide and unhide columns.
The component is capable of querying data from the DataDescriptor automatically or from code. Data query is done using the default lazy fetch implementation. Lazy fetch means getting a small amount of data at a time, to maintain normal operation speed. Once the user scrolls down to the bottom of the component and all the data has been visualized, a new amount of data is queried and visualized. Thus, the user never waits for the data to be visualized, but can access all the necessary data at every time.
You can specify a fixed width and height for the component. By default, the component automatically fits to the screen.
The component enables you to export grid data. In case of data export, all available data in the database is exported. The possible export formats are Microsoft Excel, CSV, TBS or text file. The implementation of data export is included in the grid component, but it is only accessible from code (hidden from the user).
Supported events:
AnimationStart
AnimationEnd
,
Drop
,
DragStart
,
DragEnd
HotKey
,
RowClick
,
RowDoubleClick
,
HeaderClick
,
HeaderDoubleClick
,
NextPageRequest
,
FetchDone
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected BaseFilter<?>
protected FilterType
protected ListGridContextMenuOrder
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
Fields inherited from interface com.jbstrap.ui.interfaces.Exportable
AUTO_SIZE_COLUMNS, CLIENT, COLUMNS, CRITERIA, CUSTOM_EXPORTER_CLASS, DATE_FORMATS, EXPORT_TYPE, EXTENSION, FILENAME, ONLY_DISPLAYED_COLUMNS, ORDER, SKIP_UNTITLED_COLUMNS
-
Constructor Summary
ConstructorDescriptionListGrid()
Creates an empty list grid.ListGrid
(DataDescriptor dataDescriptor) Creates a list grid based on the language code specified in the DataDescriptor.ListGrid
(DataDescriptor dataDescriptor, String language) Creates a list grid based on the language code specified in the DataDescriptor.Creates an empty list grid using the specified language code.ListGrid
(String id, DataDescriptor dataDescriptor) Creates a list grid based on the language code specified in the DataDescriptor.ListGrid
(String id, DataDescriptor dataDescriptor, String language) Creates a list grid based on the language code specified in the DataDescriptor.Creates an empty list grid using the specified language code. -
Method Summary
Modifier and TypeMethodDescriptionaddColumn
(ListGridColumn column) Adds a new column to the list grid component.final ListGrid
addComponent
(Component<?> component) No further components can be added to the grid.final ListGrid
Adds an event handler to the grid for the grid header click event.final ListGrid
Adds an event handler to the grid for the grid header double-click event.final ListGrid
Adds an event handler to the grid.final ListGrid
Adds a sorting rule to the previous grid sorting rules.final ListGrid
Adds a new record to the list grid.final ListGrid
final ListGrid
addRecords
(List<Record> records) Adds multiple records to the grid.final ListGrid
addRecords
(List<Record> records, boolean persisted) Row click even handler for the grid.final ListGrid
Adds a double-click event handler for the grid row.void
The operations to be executed after the drawing of the componentfinal ListGrid
clear()
Empties the list grid component; removes all rows and records from the list grid.final ListGrid
Removes all sorting rules from the grid.deleteRow
(int rowIndex) Removes a row from the grid.Deselecting all rows in the grid.deselectRange
(int firstRow, int lastRow) Deselects all rows that fall within the specified range.deselectRow
(int rowIndex) Removes a row from the grid.deselectRow
(ListGridRow row) Removes a row from the grid.Disables the list grid filter.protected String
drawComponent
(Component<?> component) exportData
(Parameters params) Exports the data using the settings specified in theParameters
parameter.This method implements actual data retrieval.Queries data from the database The query uses the sort order, the default and custom filter criteria.<T> T
getCellValue
(int rowIndex, String columnName) Gets the cell value.<T> T
getCellValue
(ListGridRow row, String columnName) Gets the cell value.final ListGridColumn
Gets a column of the list grid by its name.Gets all the column names in the list grid.final Collection<ListGridColumn>
Gets list grid columns.Gets every previously added subcomponentGets list grid filter criteria.Gets list grid DataDescriptor.Gets list grid default filter criteria.Gets the default formatter for the specified column.Gets the default sort rules for the list grid.final List<ListGridRow>
Gets deleted grid rows.Gets the placeholder for an empty header.Gets the list grid fetch type.BaseFilter<?>
Gets the filter component of ListGridGets the filter criterion used for the query.Gets the list grid filter type.Gets the display order of the columns in the context menu.final List<ListGridRow>
Gets modified grid rows.final List<ListGridRow>
Gets all newly added grid rows (persisted records).Gets all sorting rules.getRowByIndex
(long index) Gets a row by row index.int
Gets list grid rows.getRows()
Gets all rows in a list grid.getRowState
(int rowIndex) Gets the state of a row.final ListGridRow
Gets the selected row in the grid.final List<ListGridRow>
Gets all selected rows from the grid.final ListGrid
hideColumn
(String columnName) Hides a column in the grid.void
init()
The component initialization method.Inverts the selection of all rows in the grid.invertSelection
(int rowIndex) Inverts row selection.Inverts row selection.invertSelectionRange
(int firstRow, int lastRow) Inverts the selection of all rows within the specified range.boolean
Sets the automatic data fetch.boolean
Gets the automatic close option for the context menu.boolean
Sets column filter option to enabled.boolean
Checks the column rearrange option.boolean
Checks the resize option.boolean
isEmpty()
Checks if the list grid is empty (does not contain any data rows).final boolean
Checks if the user is allowed to filter list grid data.boolean
Checks if the vertical scrollbar is displayed on the page margin.final boolean
Checks if the header is visible.final boolean
Checks if grid data has been modified since the last query.final boolean
Sets if the multiselect option is enabled.boolean
protected void
protected void
void
This method is called if the user starts filtering via the filter componentvoid
onFilter
(FilterbarFilteringEvent event) Filter handlingvoid
void
void
onRowClick
(ListGridRowClickEvent event) void
onShow()
The operations to be executed after the component is displayed on the clientvoid
onSort
(ListGridSortEvent event) final ListGrid
removeColumn
(String columnName) Removes a column from the list grid row by referencing its name.final ListGrid
Deletes the default formatter for the column type.final ListGrid
removeOrder
(Order order) Removes a sorting rule from the grid.final ListGrid
save()
Saves all grid modifications to the database within a single database transaction.final ListGrid
save
(Transaction transaction) Saves all grid modifications to the database within a single database transaction.final ListGrid
scrollToRow
(int rowindex) Scrolls down the list grid to the specified row.Scrolls to the top of the list grid; displays the top of the data queried.Selects all rows in the grid.selectRange
(int firstRow, int lastRow) Selects all rows that fall within the specified range.selectRow
(int rowIndex) Selects a row in the grid.selectRow
(ListGridRow row) Selects a row in the grid.setAutoFetchData
(boolean autoFetch) Sets automatic data fetch from the database.setColumnListAutoClose
(boolean autoClose) Sets if the context menu should automatically close if the user selects a column in the context menu.setColumnListFilterable
(boolean filterable) Sets the column filter option in the context menu by specifying the column name.setColumnMovable
(boolean columnMovable) Sets the column rearrange option.setColumnResizable
(boolean columnResizable) Sets the column resize option.setCustomFetch
(FetchEvent fetchEvent) Sets a custom query.final ListGrid
setCustomFilter
(Class<? extends BaseFilter<?>> filterClass) Sets a custom filter component for the list grid.final ListGrid
setDataDescriptor
(DataDescriptor dataDescriptor) Sets a DataDescriptor for the list grid component, creates and adds the DataDescriptor columns to the grid.final ListGrid
setDataDescriptor
(DataDescriptor dataDescriptor, boolean buildColumns) Sets the DataDescriptor for the list grid and checks if the columns for the list grid should be created.setDefaultCriteria
(Criteria defaultCriteria) Sets the filter criterion used to filter data.setDefaultFormatter
(ListGridColumnType type, ListGridCellFormatter formatter) Sets the default formatter for the grid using the specified column type.final ListGrid
setDefaultOrder
(Order order) Sets the default sort type for the list grid.final ListGrid
setDefaultOrders
(Order... orders) Sets the default sort order for the list grid.final ListGrid
setDefaultOrders
(List<Order> orders) Sets the default sort order for the list grid.setEmptyPlaceholderTitle
(String title) Sets the placeholder for an empty header.setEnabled
(boolean enabled) Enabling/disabling the grid on the interface.setFetchType
(ListGridFetchType fetchType) List grid data fetch type.setFilterCriteria
(Criteria criteria) Sets the filter criterion used to query the data.final ListGrid
setFilterType
(FilterType filterType) Sets the grid filter type.setFixedScrollbarPosition
(boolean fixedScrollbarPosition) Sets the list grid scrollbar position.final ListGrid
Sets the order of the columns in the context menu.final ListGrid
Sets the grid heightfinal ListGrid
setMultiselect
(boolean multiselect) Sets the multiple selection option.final ListGrid
Sets the order of the grid.final ListGrid
Sets the grid order using several rules.setSortable
(boolean sortable) setStriped
(boolean stripped) final ListGrid
Sets the grid widthfinal ListGrid
showColumn
(String columnName) Unhides a previously hidden column in the grid.final ListGrid
showHeader
(boolean showHeader) Sets the list grid header visibility.Modifies a row in the grid.Modifies a cell in the grid.boolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, openTag, redraw, removeAllComponents, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.Fetchable
addFetchDoneHandler, fireFetchDoneEvent
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
-
Field Details
-
headerContextMenuOrder
-
filterType
-
filterBar
-
-
Constructor Details
-
ListGrid
public ListGrid()Creates an empty list grid. -
ListGrid
Creates an empty list grid using the specified language code.- Parameters:
language
- Language code according to which the component is created If not specified ornull
is set, the framework’s default language code is used. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE
.
-
ListGrid
Creates an empty list grid using the specified language code.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)language
- Language code according to which the component is created If not specified ornull
is set, the framework’s default language code is used. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE
.
-
ListGrid
Creates a list grid based on the language code specified in the DataDescriptor.
The method creates the list grid component and adds the DataDescriptor columns to the grid.
DataDescriptor columns are created based on the following:The column type is determined using the DataDescriptor type as in the below table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts are aligned to the left and no formatter is used to display the column.You can use DataDescriptor parameters to specify the default settings of the column and other settings. The component uses the following parameters of the DataDescriptor column:
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 formatter in the parameter. If the parameter is not specified, the default formatter for the column 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.FORMATTER
- You can specify the column width by setting this parameter. Width is specified using the CSS3. If the parameter is not specified, column width is automatically defined. All columns are set to the same width and fit to the width of the grid. Columns are set to a minimum width of 150 pixels. If you have many columns in the grid, it is horizontally scrollable.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done based on the default alignment for the column data type. 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
) - "left" - Column data is aligned to the right. (
ListGridColumnAlignment.LEFT
)
- Parameters:
dataDescriptor
- DataDescriptor instance used for building the ListGrid component
- "left" - Column data is aligned to the left. (
-
ListGrid
Creates a list grid based on the language code specified in the DataDescriptor.
The method creates the list grid component and adds the DataDescriptor columns to the grid.
DataDescriptor columns are created based on the following:The column type is determined using the DataDescriptor type as in the below table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts are aligned to the left and no formatter is used to display the column.You can use DataDescriptor parameters to specify the default settings of the column and other settings. The component uses the following parameters of the DataDescriptor column:
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 formatter in the parameter. If the parameter is not specified, the default formatter for the column 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.FORMATTER
- You can specify the column width by setting this parameter. Width is specified using the CSS3. If the parameter is not specified, column width is automatically defined. All columns are set to the same width and fit to the width of the grid. Columns are set to a minimum width of 150 pixels. If you have many columns in the grid, it is horizontally scrollable.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done based on the default alignment for the column data type. 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
) - "left" - Column data is aligned to the right. (
ListGridColumnAlignment.LEFT
)
- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)dataDescriptor
- DataDescriptor instance used for building the ListGrid component
- "left" - Column data is aligned to the left. (
-
ListGrid
Creates a list grid based on the language code specified in the DataDescriptor.
The method creates the list grid component and adds the DataDescriptor columns to the grid.
DataDescriptor columns are created based on the following:The column type is determined using the DataDescriptor type as in the below table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts are aligned to the left and no formatter is used to display the column.You can use DataDescriptor parameters to specify the default settings of the column and other settings. The component uses the following parameters of the DataDescriptor column:
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 formatter in the parameter. If the parameter is not specified, the default formatter for the column 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.FORMATTER
- You can specify the column width by setting this parameter. Width is specified using the CSS3. If the parameter is not specified, column width is automatically defined. All columns are set to the same width and fit to the width of the grid. Columns are set to a minimum width of 150 pixels. If you have many columns in the grid, it is horizontally scrollable.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done based on the default alignment for the column data type. 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
) - "left" - Column data is aligned to the right. (
ListGridColumnAlignment.LEFT
)
- Parameters:
dataDescriptor
- DataDescriptor instance used for building the ListGrid componentlanguage
- Language code according to which the component is created If not specified ornull
is set, the framework’s default language code is used. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE
.
- "left" - Column data is aligned to the left. (
-
ListGrid
Creates a list grid based on the language code specified in the DataDescriptor.
The method creates the list grid component and adds the DataDescriptor columns to the grid.
DataDescriptor columns are created based on the following:The column type is determined using the DataDescriptor type as in the below table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts are aligned to the left and no formatter is used to display the column.You can use DataDescriptor parameters to specify the default settings of the column and other settings. The component uses the following parameters of the DataDescriptor column:
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 formatter in the parameter. If the parameter is not specified, the default formatter for the column 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.FORMATTER
- You can specify the column width by setting this parameter. Width is specified using the CSS3. If the parameter is not specified, column width is automatically defined. All columns are set to the same width and fit to the width of the grid. Columns are set to a minimum width of 150 pixels. If you have many columns in the grid, it is horizontally scrollable.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done based on the default alignment for the column data type. 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
) - "left" - Column data is aligned to the right. (
ListGridColumnAlignment.LEFT
)
- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)dataDescriptor
- DataDescriptor instance used for building the ListGrid componentlanguage
- Language code according to which the component is created If not specified ornull
is set, the framework’s default language code is used. The default language of the framework is set via the JBStrap parameterJBStrapParamType.DEFAULT_LANGUAGE
.
- "left" - Column data is aligned to the left. (
Method Details
-
init
Description copied from class:Component
The component initialization method.Empty method, only needs to be overwritten when making a custom component, that needs to call an initializing JavaScript on the client side. The method is called by the framework after the component is drawn, but before the afterDraw() method. The use of this method during application development is not allowed. This method is meant for inner use only.
- Overrides:
init
in classComponent<ListGrid>
- Throws:
JavaScriptLoadError
- If there was a JavaScript error during the initialization.
-
setDataDescriptor
Sets a DataDescriptor for the list grid component, creates and adds the DataDescriptor columns to the grid. If a new DataDescriptor is added to the list grid, all the columns are removed from the grid and only those in the specified DataDescriptor are displayed.The column type is determined using the DataDescriptor type as in the below table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts are aligned to the left and the column does not have a formatter class.DataDescriptor column parameters are used to override the default settings of the newly created column and also to specify other settings. The component uses the following parameters of the DataDescriptor column:
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 CSS3. If the parameter is not specified, column width is automatically defined. All columns will have the same width and fit to the total width of the grid. The minimum width for the columns is 150 pixels. If there is a large amount of columns, the grid can be horizontally scrolled.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done using the default alignment for the column. You can use the parameter to provide the following values:- "left" - Column data is aligned to the left. (
ListGridColumnAlignment.LEFT
) - "center" - Column data is center-aligned. (
ListGridColumnAlignment.CENTER
) - "right" - Column data is aligned to the right. (
ListGridColumnAlignment.RIGHT
)
- Specified by:
setDataDescriptor
in interfaceBasedOnDataDescriptor<ListGrid>
- Parameters:
dataDescriptor
- DataDescriptor instance used for building the ListGrid component- Returns:
- List grid component
- "left" - Column data is aligned to the left. (
-
setDataDescriptor
Sets the DataDescriptor for the list grid and checks if the columns for the list grid should be created.The column type is determined using the DataDescriptor column type as in the following table:
Data source column type Created column DataDescriptorColumnDatatype.DATE
The created column has the type ListGridColumnType.DATE
. By default, dates are center-aligned and displayed using the formatterListGridDateFormatter
.DataDescriptorColumnDatatype.DATETIME
The created column has the type ListGridColumnType.DATETIME
. By default, time is center-aligned and displayed using the formatterListGridDateTimeFormatter
.DataDescriptorColumnDatatype.INTEGER
DataDescriptorColumnDatatype.LONG
DataDescriptorColumnDatatype.DOUBLE
The created column has the type ListGridColumnType.NUMBER
. Numbers are aligned to the right and displayed using the formatterListGridNumberFormatter
.DataDescriptorColumnDatatype.BOOLEAN
The created column has the type ListGridColumnType.BOOLEAN
. Dates are center-aligned and displayed using the formatterListGridBooleanFormatter
.DataDescriptorColumnDatatype.TEXT
The created column has the type ListGridColumnType.TEXT
. Texts by default are aligned to the left and no formatter class is set.DataDescriptor column parameters are used to override the default settings of the newly created column and also to specify other settings. The component uses the following DataDescriptor column parameters:
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 you do not specify a parameter, the default formatter for the column 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 CSS3. If the parameter is not specified, the column width is automatically set. All columns will have a uniform width value and fit to the overall width of the grid. Columns have a minimum width of 150 pixels. If there is a large amount of columns, the grid can be scrolled horizontally.MetaParamName.ALIGN
- This parameter specifies the alignment of data within the columns. If the parameter is not specified, data alignment is done using the default alignment for the column. You can use the parameter to provide the following values:- "left" - Column data is aligned to the left. (
ListGridColumnAlignment.LEFT
) - "center" - Column data is center-aligned. (
ListGridColumnAlignment.CENTER
) - "right" - Column data is aligned to the right. (
ListGridColumnAlignment.RIGHT
)
- Parameters:
dataDescriptor
- DataDescriptor instance used for building the ListGrid componentbuildColumns
- Iftrue
is specified, the columns in the DataDescriptor are built Otherwise, they are not built.- Returns:
- List grid component
- "left" - Column data is aligned to the left. (
-
getDataDescriptor
Gets list grid DataDescriptor.- Specified by:
getDataDescriptor
in interfaceBasedOnDataDescriptor<ListGrid>
- Returns:
- The DataDescriptor instance containing the list grid data, or
null
if no DataDescriptor is set for the list grid
-
addColumn
Adds a new column to the list grid component.- Parameters:
column
- An instance of the column to be added to the component The column specified here is displayed as the last one, following all other columns.- Returns:
- List grid component
-
getColumns
Gets list grid columns.- Returns:
- A list of columns in the list grid component, or
null
if the list grid does not contain any columns
-
getColumn
Gets a column of the list grid by its name.- Parameters:
columnName
- Column name- Returns:
- Column object with the specified name or
null
if there are no columns in the list grid by the specified name
-
getColumnNames
Gets all the column names in the list grid.- Returns:
- A list of columns in the list grid component, or
null
if the list grid does not contain any columns
-
removeColumn
Removes a column from the list grid row by referencing its name.- Parameters:
columnName
- Name of the column to be removed- Returns:
- List grid component
-
hideColumn
Hides a column in the grid. If a column is hidden, it is not visible to the user, but it is made visible again by using the context menu.- Parameters:
columnName
- Column name to be hidden- Returns:
- List grid component
-
showColumn
Unhides a previously hidden column in the grid. Once a column has been unhidden, it is visible to the user, but can be hidden again by using the context menu.- Parameters:
columnName
- Column name to be displayed- Returns:
- List grid component
-
setFilterType
Sets the grid filter type. If the filter type is specified, the filter component is displayed above the list grid. The user is able to filter the data with the help of the filter component.- Parameters:
filterType
- Filter type for the list grid data Available filter types are listed in the enumFilterType
. Ifnull
is specified, the user is unable to filter the list grid data.- Returns:
- List grid component
-
isFilterable
public final boolean isFilterable()Checks if the user is allowed to filter list grid data.- Returns:
- If
true
, the user is allowed to filter list grid data. Otherwisefalse
.
-
getFilterType
Gets the list grid filter type.- Returns:
- List grid filter type
-
disableFilter
Disables the list grid filter. If the method is called, the user will be unable to filter the displayed data and the filter component disappears.- Returns:
- List grid component
-
setCustomFilter
Sets a custom filter component for the list grid.- Parameters:
filterClass
- Class implementing a custom filter component- Returns:
- List grid component
- Throws:
NullPointerException
- Thrown if the specified name isnull
- See Also:
-
showHeader
Sets the list grid header visibility. By default, the list grid is visible. If set to invisible, column headers and the adaptive filter disappear.- Parameters:
showHeader
- Iftrue
is set, the header is visible. Iffalse
, the header is hidden.- Returns:
- List grid component
-
isHeaderShown
public final boolean isHeaderShown()Checks if the header is visible.- Returns:
- If
true
, the list grid header is visible, otherwisefalse
-
setMultiselect
Sets the multiple selection option. By default, multiselect is disabled and the user is able to select only a single row. If enabled, the user is allowed to select multiple rows.- Parameters:
multiselect
- Iftrue
is set, the multiselect option is enabled and the user is allowed to select multiple rows Iffalse
is set, the multiselect is disabled and the user is allowed to select only a single row- Returns:
- List grid component
-
isMultiselect
public final boolean isMultiselect()Sets if the multiselect option is enabled.- Returns:
- If
true
, the multiselect option is enabled and the user is allowed the select multiple rows Iffalse
, the multiselect option is disabled and the user is allowed to select only a single row.
-
setAutoFetchData
Sets automatic data fetch from the database. By default, this option is disabled and data fetch is performed automatically after the grid is displayed.- Specified by:
setAutoFetchData
in interfaceFetchable<ListGrid>
- Specified by:
setAutoFetchData
in interfaceFilterable<ListGrid>
- Parameters:
autoFetch
- Iftrue
is set, data fetch is automatically performed; otherwise data fetch must be implemented from code by calling thefetchData()
method- Returns:
- List grid component
-
isAutoFetchData
public boolean isAutoFetchData()Sets the automatic data fetch.- Specified by:
isAutoFetchData
in interfaceFetchable<ListGrid>
- Specified by:
isAutoFetchData
in interfaceFilterable<ListGrid>
- Returns:
- If
true
is set, the data fetch is performed automatically, otherwisefalse
is set
-
setHeaderContextMenuOrder
Sets the order of the columns in the context menu. By default, columns are displayed in the order they were added to the grid.- Parameters:
order
- Column display order Available ordering sequences are listed in the enumListGridContextMenuOrder
. Ifnull
is set, the default order is used. Columns are displayed in the order they were added to the grid.- Returns:
- List grid component
-
getHeaderContextMenuOrder
Gets the display order of the columns in the context menu.- Returns:
- Column order in the context menu
-
setColumnResizable
Sets the column resize option. The default setting is that the user is allowed to resize columns.- Parameters:
columnResizable
- Iftrue
, the user is allowed to resize columns- Returns:
- List grid component
-
isColumnResizable
public boolean isColumnResizable()Checks the resize option.- Returns:
- If
true
, the user is allowed to resize columns
-
setColumnMovable
Sets the column rearrange option. The default setting is that the user is allowed to move the columns from one position to the other.- Parameters:
columnMovable
- Iftrue
is set, the user is allowed to move columns in the grid Otherwise the columns cannot be moved.- Returns:
- List grid component
-
isColumnMovable
public boolean isColumnMovable()Checks the column rearrange option.- Returns:
- If
true
, the user is allowed to move columns in the grid, otherwisefalse
-
setColumnListFilterable
Sets the column filter option in the context menu by specifying the column name. By default, the user is allowed to filter the columns in the context menu.- Parameters:
filterable
- Iftrue
is set, the user is allowed to filter the columns in the context menu Otherwise,false
is set.- Returns:
- List grid component
-
isColumnListFilterable
public boolean isColumnListFilterable()Sets column filter option to enabled.- Returns:
- If
true
, the user is allowed to filter the columns in the context menu, otherwisefalse
-
setColumnListAutoClose
Sets if the context menu should automatically close if the user selects a column in the context menu. By default, the context menu automatically closes after a column is selected.- Parameters:
autoClose
- Iftrue
is set, the context menu closes automatically after selecting a column Iffalse
was set, the context menu remains open and you can close it only by clicking on the “Close” button.- Returns:
- List grid component
-
isColumnListAutoClose
public boolean isColumnListAutoClose()Gets the automatic close option for the context menu.- Returns:
- If
true
is set, the context menu automatically closes after selecting a column. Otherwisefalse
.
-
setFetchType
List grid data fetch type. The default fetch setting is theListGridFetchType.LAZY
fetch type.- Parameters:
fetchType
- Data fetch type Data fetch types are listed in the methodListGridFetchType
. Ifnull
is specified, the default LAZY fetch type is used.- Returns:
- List grid component
-
getFetchType
Gets the list grid fetch type.- Returns:
- List grid fetch type
-
setDefaultCriteria
Sets the filter criterion used to filter data. The filter criterion specified here cannot be modified by filter components. The criterion is used in all filter operations, joined to the user’s custom filter criterion with an AND operator.- Parameters:
defaultCriteria
- Default filter criterion Ifnull
is set, there is no default filter criterion for the grid.- Returns:
- List grid component
- See Also:
-
getDefaultCriteria
Gets list grid default filter criteria.- Returns:
- The default filter citerion for the list grid or
null
if there are no filter criteria defined for the grid
-
setFilterCriteria
Sets the filter criterion used to query the data. The filter criterion specified here can be modified or overwritten using the filter component. If a criterion is specified and there is a filter component in the grid, the filter component is displayed using the specified criterion. The filter criterion specified here is joined to the default filter criterion with an AND operator.- Specified by:
setFilterCriteria
in interfaceFilterable<ListGrid>
- Parameters:
criteria
- Filter criterion used to query the data Ifnull
is set, there is no default filter criterion for the grid.- Returns:
- List grid component
- Throws:
IllegalArgumentException
- Thrown if the specified filter criterion does not correspond to the displayed filter component
-
getFilterCriteria
Gets the filter criterion used for the query.- Returns:
- The filter criterion specified by the user or
null
if the user has not specified any filter criteria
-
setDefaultOrder
Sets the default sort type for the list grid. The sort type specified here is applied if the user does not sort the data in a different way.- Parameters:
order
- Default sort order Ifnull
is set, the default sort order is deleted.- Returns:
- List grid component
-
setDefaultOrders
Sets the default sort order for the list grid. The sort rules specified here is applied if the user does not sort the data in a different way.- Parameters:
orders
- An enumeration of default sort rules. Rules are listed in the order of their application. Ifnull
is specified, the default sort rules are deleted.- Returns:
- List grid component
-
setDefaultOrders
Sets the default sort order for the list grid. The sort rules specified here is applied if the user does not sort the data in a different way.- Parameters:
orders
- An enumeration of default sort rules. Rules are listed in the order of their application. If not specified ornull
is set, the default sort rules are deleted.- Returns:
- List grid component
-
getDefaultOrders
Gets the default sort rules for the list grid.- Returns:
- A list of default sort rules for the list grid or
null
if there is no default sort rule defined for the list grid
-
getRowCount
public int getRowCount()Gets list grid rows. The returned value is not the count of data records, but the count of rows in the list grid.- Returns:
- List grid row count
-
isEmpty
public boolean isEmpty()Checks if the list grid is empty (does not contain any data rows).- Returns:
- If
true
, the list grid is empty, otherwisefalse
-
addRecord
Adds a new record to the list grid. Data of the newly added record are displayed only on the interface, but are not added to the database.- Parameters:
newRecord
- An instance of the record we want to add to the grid- Returns:
- List grid component
- Throws:
IllegalArgumentException
- Thrown if you want to add a record to a grid with no columns
-
addRecord
- Parameters:
newRecord
- An instance of the record we want to add to the gridpersisted
- Iftrue
is specified, the grid takes the record as persisted and will not save it to the database Iffalse
is specified, records are not persisted and will not be saved to the database.- Returns:
- List grid component
- Throws:
IllegalArgumentException
- Thrown if you want to add a record to a grid with no columns
-
addRecords
Adds multiple records to the grid. Data of the newly added record are displayed only on the interface, but are not added to the database.- Parameters:
records
- A list of records to be added to the grid- Returns:
- List grid component
- Throws:
IllegalArgumentException
- Thrown if you want to add a record to a grid with no columns
-
addRecords
- Parameters:
records
- A list of records to be added to the gridpersisted
- Iftrue
is set, the grid takes the record as persisted and will not save it to the database Iffalse
is specified, records are not persisted and will be saved to the database.- Returns:
- List grid component
- Throws:
IllegalArgumentException
- Thrown if you want to add a record to a grid with no columns
-
fetchData
Queries data from the database The query uses the sort order, the default and custom filter criteria. All the previous rows and records are removed from the grid. The grid is populated with the records returned by the query.- Specified by:
fetchData
in interfaceFetchable<ListGrid>
- Specified by:
fetchData
in interfaceFilterable<ListGrid>
- Returns:
- List grid component
- Throws:
IllegalStateException
- Thrown if the method is called by a list grid with no DataDescriptor specified
-
clear
Empties the list grid component; removes all rows and records from the list grid.- Returns:
- List grid component
-
scrollToTop
Scrolls to the top of the list grid; displays the top of the data queried.- Returns:
- List grid component
-
scrollToRow
Scrolls down the list grid to the specified row. If the specified row is not on the interface, the grid automatically queries the data from the database until the requested row is available, then it scrolls down to the specific row. If the specified row is not available, the method does nothing, all the data is retrieved. Note that if you specify a large number, a lot of data values will be retrieved and this results in a long data retrieval time.- Parameters:
rowindex
- Row index until which the grid is scrolled Start index is 0.- Returns:
- List grid component
-
setHeight
Sets the grid height- Parameters:
height
- Grid height as defined in the CSS3 standard- Returns:
- List grid component
-
setWidth
Sets the grid width- Parameters:
width
- Grid width as defined in the CSS3 standard- Returns:
- List grid component
-
getRowByIndex
Gets a row by row index.- Parameters:
index
- Index of the row we want to get Start index is 0.- Returns:
- Row object corresponding to the specified index or
null
if there is no row in the grid by the specified index
-
selectRow
Selects a row in the grid.- Parameters:
rowIndex
- Index of the row to be selected If there is no row in the grid by the specified row index, the method does nothing.- Returns:
- List grid component
-
selectRow
Selects a row in the grid.- Parameters:
row
- An instance of the row to be selected If the specified instance is not in the grid, or it is deleted ornull
is specified, the method does nothing.- Returns:
- List grid component
-
deselectRow
Removes a row from the grid. Data from the deleted row disappear from the grid, but the record is not deleted. The record is stored in the memory as a deleted record.- Parameters:
rowIndex
- The index of the row to be deleted If there is no row in the grid by the specified row index, the method does nothing.- Returns:
- List grid component
-
deselectRow
Removes a row from the grid. Data from the deleted row disappear from the grid, but the record is not deleted. The record is stored in the memory as a deleted record.- Parameters:
row
- Row instance to be deleted If the specified instance is not in the grid, ornull
is specified, the method does nothing.- Returns:
- List grid component
-
invertSelection
Inverts row selection. Inverting a selection means deselecting the row. Contrarily, if the row has been selected, it will be selected.- Parameters:
rowIndex
- Row index used to invert the selection- Returns:
- List grid component
-
invertSelection
Inverts row selection. Inverting a selection means deselecting the row. Contrarily, if the row has been selected, it will be selected.- Parameters:
row
- Instance of the row used to invert the selection- Returns:
- List grid component
-
selectAllRows
Selects all rows in the grid.- Returns:
- List grid component
-
deselectAllRows
Deselecting all rows in the grid.- Returns:
- List grid component
-
invertAllRows
Inverts the selection of all rows in the grid. The method deselects all selected rows in the grid and selects all unselected rows.- Returns:
- List grid component
-
selectRange
Selects all rows that fall within the specified range. The range is specified by row indices. Start index is 0. Selects all the rows that fall within the range, lower and upper boundaries of the range.- Parameters:
firstRow
- The start index of the selection rangelastRow
- The end index of the selection range- Returns:
- List grid component
-
deselectRange
Deselects all rows that fall within the specified range. The range is specified by row indices. Start index is 0. Deselects all rows that fall within the specified range, including the lower and upper boundaries of the range. Deselect row range in a grid.- Parameters:
firstRow
- The start index of the selection rangelastRow
- The end index of the selection range- Returns:
- List grid component
-
invertSelectionRange
Inverts the selection of all rows within the specified range. The range is specified by row indices. Start index is 0. Inverts the selection of all rows within the specified range, including the lower and upper boundaries of the range. Inverting the selection means deselecting previously selected rows. Contrarily, previously unselected rows will be selected.- Parameters:
firstRow
- The start index of the selection rangelastRow
- The end index of the selection range- Returns:
- List grid component
-
getSelectedRow
Gets the selected row in the grid.- Returns:
- Instance of the row selected in the grid
If multiple rows are selected in the grid, the method returns the instance of the first row.
If no rows are selected, the return value is
null
.
-
getSelectedRows
Gets all selected rows from the grid.- Returns:
- A list of instances of all selected rows If the grid does not contain any selected rows, the return value is an empty list.
-
addRowClickHandler
Row click even handler for the grid.- Parameters:
handler
- Row click event handler implementation- Returns:
- List grid component
-
addRowDoubleClickHandler
Adds a double-click event handler for the grid row.- Parameters:
handler
- Double-click event handler implementation for the row- Returns:
- List grid component
-
addHeaderClickHandler
Adds an event handler to the grid for the grid header click event.- Parameters:
handler
- Grid header click event handler implementation- Returns:
- List grid component
-
addHeaderDoubleClickHandler
Adds an event handler to the grid for the grid header double-click event.- Parameters:
handler
- Grid header double-click event handler implementation- Returns:
- List grid component
-
addNextPageRequestHandler
Adds an event handler to the grid. The event is raised when the next page is requested.- Parameters:
handler
- Event handler implementation for the next page- Returns:
- List grid component
-
setOrder
Sets the order of the grid. The previous sort order is deleted and the grid is sorted using the rule specified here.- Parameters:
order
- Grid sort rule If not specified ornull
is set, the grid is displayed unsorted.- Returns:
- List grid component
-
setOrders
Sets the grid order using several rules. The previous sort order is deleted and the grid is sorted using the rule specified here. Rules are processed in their respective order in the specified list.- Parameters:
orders
- List containing sort rules If not specified ornull
is set, the grid is displayed unsorted.- Returns:
- List grid component
-
addOrder
Adds a sorting rule to the previous grid sorting rules.- Parameters:
order
- Sorting rule to be added to the grid- Returns:
- List grid component
-
removeOrder
Removes a sorting rule from the grid.- Parameters:
order
- Sorting rule to be removed from the grid- Returns:
- List grid component
-
clearOrders
Removes all sorting rules from the grid.- Returns:
- List grid component
-
getOrders
Gets all sorting rules.- Returns:
- A list of all specified sorting rules If the grid does not contain any sorting rules, an empty list is returned.
-
setDefaultFormatter
Sets the default formatter for the grid using the specified column type.- Parameters:
type
- Column type for which the default formatter is set Available types are listed in the enumListGridColumnType
.formatter
- Default formatter implementation for the specified column Ifnull
is specified, the column type’s default formatter is deleted.- Returns:
- List grid component
- Throws:
NullPointerException
- Thrown if the specified column type isnull
-
getDefaultFormatter
Gets the default formatter for the specified column.- Parameters:
type
- Column type for the default formatter Available column types are listed in the enumListGridColumnType
.- Returns:
- Default formatter implementation for the specified column type or
null
, if there is no default formatter for the column type
-
removeDefaultFormatter
Deletes the default formatter for the column type.- Parameters:
type
- Column type whose default formatter is to be deleted- Returns:
- List grid component
-
getRows
Gets all rows in a list grid.- Returns:
- A list containing all rows in a list grid. If the list does not contain any rows, an empty list is returned.
-
exportData
Description copied from interface:Exportable
Exports the data using the settings specified in theParameters
parameter. This method implements a general file export process by default. A custom export process can be implemented in any class by overwriting this method.
During the export process, data are retrieved using lazy fetch. The number of records in a query can be set by specifying theJBStrapParamType.EXPORT_FETCH_SIZE
. The maximum number of rows to be exported can be specified using theJBStrapParamType.MAX_EXPORTED_ROW_COUNT
parameter.- Specified by:
exportData
in interfaceExportable<Fetchable<ListGrid>>
- Parameters:
params
- Parameters to be specified: (asterisk means required):
Parameter name Parameter value Default parameter value Parameter description client* Client
No The client initiating the export process, the exported file is downloaded to this client type ExportTypes
ExportTypes.CSV
Export file type. It is required to specify the type or customExporterClass customExportClass DataExporter
interface implementationNo If this parameter is specified, the type parameter is not processed either. It is required to specify the type or customExporterClass criteria Criteria
No Filter criterion for export data order List< Order
>No Determines the order of data values to be exported; specify multiple order criteria columns* Map<String, String> No Specifies the export fields. Key: field name, value: field label. If this parameter is not specified, the returned query records are used. If the number of records is 0 (no records fulfil the query criteria), an exception is thrown filename String export.unnamed.file message resource by default: Exported file Export file name skipUntitledColumns boolean true
Sets whether unlabeled fields should be included in the export file dateFormats Map<String, String> No In case of date type fields, you can specify the field pattern. Key: field name, value: field pattern. Use the SimpleDateFormat
to process the patternautoSizeColumns boolean false Sets auto column size in the export file - Returns:
- The component
-
deleteRow
Removes a row from the grid. The specified row is deleted from the interface, but the records itself is not deleted from the database. The record’s state is changed to ‘deleted’.- Parameters:
rowIndex
- The index of the row to be deleted from the grid Start index is 0.- Returns:
- List grid component
-
updateRow
Modifies a row in the grid. All data values in a row are modified on the interface, but the data values are not modified in the database. The record state is changed to ‘modified’.- Parameters:
rowIndex
- The index of the row to be modified Start index is 0. If there is no row in the list grid by the specified index, or the index references a previously deleted row, the method does nothing.newRecord
- An instance of the record containing new data All data values in this record are inserted into row data. If both records have the same attribute, the previous one is overwritten with data from the specified record. If the previous record contains an attribute which is not included in the record specified here, it remains the same.- Returns:
- List grid component
-
updateRow
Modifies a cell in the grid. The modified record is inserted into the grid row, but is not modified in the database. The record state is changed to ‘modified’.- Parameters:
rowIndex
- Row index of the cell to be modified If an index is specified which does not identify a row in the grid, or the specified row has been previously deleted, the method does nothing.columnName
- Column name of the cell to be modified If a non-existent column name is entered, the data is inserted into the record, but no visible change is made to the interface.newValue
- New value which overwrites the previous one- Returns:
- List grid component
-
isModified
public final boolean isModified()Checks if grid data has been modified since the last query.- Returns:
- If
true
, grid data has been changed since the last query, otherwisefalse
-
getNewRows
Gets all newly added grid rows (persisted records).- Returns:
- A list of new records; if there are no new rows in the grid, an empty list is returned
-
getDeletedRows
Gets deleted grid rows.- Returns:
- A list of deleted grid rows If there are no deleted rows in the grid, an empty list is returned.
-
getModifiedRows
Gets modified grid rows.- Returns:
- A list of modified grid rows If there are no modified rows in the grid, an empty list is returned.
-
getRowState
Gets the state of a row.- Parameters:
rowIndex
- Row index- Returns:
- The state of the row specified by the row index or
null
if there is no grid row associated identified by the index
-
save
public final ListGrid save() throws RemoveException, SaveException, DataAccessException, ConnectionExceptionSaves all grid modifications to the database within a single database transaction. The save takes place if all modifications have been successfully saved. A single unsuccessful modification causes all modifications to be reverted. Modifications are not saved.- Returns:
- List grid component
- Throws:
SaveException
- Thrown if the saving of modifications or new rows was unsuccessfulRemoveException
- Thrown if removing the specified rows was unsuccessfulDataAccessException
- Thrown if the authenticated database user has no write access to the databaseConnectionException
- Thrown if the database connection is unavailable
-
save
public final ListGrid save(Transaction transaction) throws RemoveException, SaveException, DataAccessException, ConnectionException Saves all grid modifications to the database within a single database transaction. The save takes place if all modifications have been successfully saved. A single unsuccessful modification causes all modifications to be reverted. Modifications are not saved.- Parameters:
transaction
- Database transaction handling the save operation- Returns:
- List grid component
- Throws:
SaveException
- Thrown if the saving of modifications or new rows was unsuccessfulRemoveException
- Thrown if removing the specified rows was unsuccessfulDataAccessException
- Thrown if the authenticated database user has no write access to the databaseConnectionException
- Thrown if the database connection is unavailable
-
setEnabled
Enabling/disabling the grid on the interface. If a grid is enabled/disabled on the interface, all of the enclosed components are also enabled/disabled.- Overrides:
setEnabled
in classComponent<ListGrid>
- Parameters:
enabled
- Iftrue
is specified, the grid and all the enclosed components are enabled, otherwise disabled- Returns:
- List grid component
-
getCellValue
Gets the cell value.- Type Parameters:
T
- The type which gets the value- Parameters:
rowIndex
- Row index of the referenced column Start index is 0.columnName
- Column name for data query- Returns:
- Column value
If the specified cell is a rendered one, an instance of the component in the cell is returned, otherwise cell data is returned.
If the specified row index does not identify any rows, or the specified column is not contained in the row,
null
is returned.
-
getCellValue
Gets the cell value.- Type Parameters:
T
- The type which gets the value- Parameters:
row
- Row instance containing the datacolumnName
- Column name for data query- Returns:
- Column value
If the specified cell is a rendered one, an instance of the component in the cell is returned, otherwise cell data is returned.
If the specified row is
null
or the specified column is not included in the row,null
is returned.
-
onShow
public void onShow()Description copied from class:Component
The operations to be executed after the component is displayed on the clientBy default, this is an empty method. It has to be overwritten on a component or page, if additional operations have to be executed after the component is displayed. This method is nearly identical to the afterDraw() method, they differ in when they are executed. This method runs after the component is displayed on the client. Meaning that it is executed even if the component isn't redrawn, but only set to be visible after being hidden.
-
onNextPageRequest
- Parameters:
event
- Event object
-
onRefreshData
-
onColumnShowHide
-
onRowClick
- Parameters:
event
- Original row click event object
-
onColumnResize
- Parameters:
event
- Event object
-
onColumnMove
- Parameters:
event
- Event object
-
onSort
-
addComponent
No further components can be added to the grid.- Overrides:
addComponent
in classComponent<ListGrid>
- Parameters:
component
- The component to be added- Returns:
- The component
- Throws:
UnsupportedOperationException
- Thrown every time the method is called
-
drawComponent
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
. -
afterDraw
public void afterDraw()Description copied from class:Component
The operations to be executed after the drawing of the componentBy default, this is an empty method. It has to be overwritten on a component or page if additional operations have to be executed after the drawing process. One such operation is data retrieval, which shouldn't run in constructors so that the user could see results of an operation or navigation process.
-
getCriteria
Gets list grid filter criteria.- Specified by:
getCriteria
in interfaceFilterable<ListGrid>
- Returns:
- List grid filter criterion containing default filter criteria and custom filter criteria
If
null
is set, no filter criterion is defined for the list grid.
-
setEmptyPlaceholderTitle
Sets the placeholder for an empty header. By default, the placeholder has no text.- Parameters:
title
- Placeholder text Ifnull
is set, no text is displayed in the placeholder.- Returns:
- List grid component
-
getEmptyPlaceholderTitle
Gets the placeholder for an empty header.- Returns:
- The empty header placeholder title or
null
if not setted
-
setFixedScrollbarPosition
Sets the list grid scrollbar position. By default, the list grid scrollbar is displayed on the list grid margin after the last column. If the grid is wider than the page and is horizontally scrollable, the vertical scrollbar is displayed on the page margin.- Parameters:
fixedScrollbarPosition
- Iftrue
is set, the vertical scrollbar is displayed on the page margin Otherwise, the vertical scrollbar is displayed on the list grid margin.- Returns:
- List grid component
-
isFixedScrollbarPosition
public boolean isFixedScrollbarPosition()Checks if the vertical scrollbar is displayed on the page margin.- Returns:
- If
true
is set, the vertical scrollbar is displayed on the page margin Otherwise, the vertical scrollbar is displayed on the list grid margin.
-
getComponents
Description copied from class:Component
Gets every previously added subcomponent- Overrides:
getComponents
in classComponent<ListGrid>
- Returns:
- A collection of every subcomponent that was added to the component. If there are none, the collection will be empty
-
setSortable
-
isSortable
public boolean isSortable() -
setStriped
-
getFilterComponent
Gets the filter component of ListGrid- Returns:
- The list grid filter component or
null
, if filtering is switched of on the list grid component
-
onFilter
Filter handling- Parameters:
event
- Filter event
-
onFilter
Description copied from interface:FilterBarFiltering
This method is called if the user starts filtering via the filter component- Specified by:
onFilter
in interfaceFilterBarFiltering<ListGrid>
- Parameters:
criteria
- Criterion created by the filter component to perform filtering- See Also:
-
setCustomFetch
Sets a custom query. When calling the fetchData method, the specifiedFetchEvent
implementation is called, then callback methods are run on records returned by the
onFetch
method.- Parameters:
fetchEvent
- Custom query implementation
-
fetch
public List<Record> fetch(int startRow, int endRow, Criteria criteria, List<Order> orders, Client client) throws FindException, DataAccessException Description copied from interface:Fetchable
This method implements actual data retrieval. TheFetchable.fetchData()
function runs callback methods on the returned records.- Specified by:
fetch
in interfaceFetchable<ListGrid>
- Parameters:
startRow
- The first row of the query that appears in the returned listendRow
- The last row of the query that appears in the returned listcriteria
- The criteria used during the query Ifnull
, no criteria will be used, every record is queried.orders
- The orderings that will be applied to the query results. Ifnull
, the data will not be ordered.client
- The client that started the query. Ifnull
, the query will happen without checking for access rights.- Returns:
- The list of records that meet the specified filter criteria.
- Throws:
FindException
- Occurs if an error was encountered during the queryDataAccessException
- Occurs if the user in the specified client has no access to read the data
-