Class
caplin.grid

GridColumnModel

The GridColumnModel is one of the two models that are used within a grid assembly — the other being the caplin.grid.GridRowModel. The column model allows the currently displayed columns within a grid to be accessed and/or modified, including the addition & removal of columns, the setting of sort orders on columns, and the addition of display filters on columns. Additionally, the column model allows classes to subscribe to column model level events. Classes that need to listen to column model events must implement the caplin.grid.GridColumnModelListener interface, and register themselves for these events by calling #addColumnModelListener.

Constructor Summary

Attributes Name and Description
caplin.grid.GridColumnModel()

Constructs a caplin.grid.GridColumnModel instance — end-users will never need to do this themselves since grids are fully constructed based on their XML definition files by the caplin.grid.GridComponentFactory class.

Method Summary

Attributes Name and Description
void addColumnModelListener(caplin.grid.GridColumnModelListener oColumnModelListener)

Adds a column model listener that wishes to observe events fired from this GridColumnModel.

Array addColumns(Array pColumnIdentifiers, int nStartIndex)

Adds a set of columns to the GridColumnModel that will be inserted at the specified start index.

void applyFilters()

Applies all the filters that have been added to the columns within this GridColumnModel.

void clearAllFilters()

Removes all the filters that have been added to the columns within this GridColumnModel.

void clearSort()

Removes any sort currently applied to the grid column model.

Array getActiveColumns()

Returns the list of visible columns.

Array getActiveFilters()

Returns an array of all the currently active column filters.

Array getAvailableColumns()

Returns the list of columns that are not currently being shown, but are available for addition.

caplin.grid.GridColumn getColumnById(String sColumnId)

Returns the column with specified column identifier.

caplin.grid.GridColumn getColumnByIndex(int nColumnIndex)

Returns the column identified by the specified column index.

Array getRequiredFields()

Returns the list of fields the data provider must make available so that the columns have all the necesarry information to perform updates.

caplin.grid.GridColumn getSortColumn()

Returns the column that the grid is currently using for sorting.

boolean hasColumnOrderChanged()

Determine whether the column order has changed since the grid was first opened.

void isColumnAvailable(String sColumnId)

Returns true if the column id is a column that is not presently active but could be made active

void moveColumn(int nIndex, int nNewIndex)

Moves the column from its present position to a new one.

boolean removeColumnModelListener(caplin.grid.GridColumnModelListener oColumnModelListener)

Removes a column model listener that no longer wishes to observe events fired from this GridColumnModel.

void removeColumns(int nStartIndex, int nSize)

Removes a set of columns from the GridColumnModel.

void replaceColumn(int nIndex, String sColumnId)

Replaces the column at the specified index with the specified column.

Constructor Detail

caplin.grid.GridColumnModel()

Constructs a caplin.grid.GridColumnModel instance — end-users will never need to do this themselves since grids are fully constructed based on their XML definition files by the caplin.grid.GridComponentFactory class.

Method Detail

void addColumnModelListener(caplin.grid.GridColumnModelListener oColumnModelListener)

Adds a column model listener that wishes to observe events fired from this GridColumnModel.

Parameters
caplin.grid.GridColumnModelListener oColumnModelListener The listener to add.
Throws
caplin.core.Error
If the specified column model listener is not an instance of caplin.grid.GridColumnModelListener.
See
#removeColumnModelListener

Array addColumns(Array pColumnIdentifiers, int nStartIndex)

Adds a set of columns to the GridColumnModel that will be inserted at the specified start index.

If any of the specified columns are duplicates, or if any of the specified columns are already present in the model, an array of the columns that could not be added the the model will be returned.

Parameters
Array pColumnIdentifiers The unique identifiers of the columns to be added to the model.
int nStartIndex The zero-based start index where the columns should be added.
Throws
caplin.core.Error
If any column is not an instance of caplin.grid.GridColumn, or if the position is not within the bounds of the current columns within the model.
Returns
Any columns that could not be added to the model.
See
#removeColumns
#replaceColumn
#moveColumn

void applyFilters()

Applies all the filters that have been added to the columns within this GridColumnModel.

Filters can be added one at a time, and the view will need to constantly reflect the latest state of the model, and so the caplin.grid.GridColumnModelListener#onFiltersChanged callback method will need to fire as each change happens, whereas the application of filters so that it affects the caplin.grid.GridDataProvider responsible for fetching the data may not happen until some later point, depending on how the caplin.grid.decorator.GridDecorator instance(s) used to add these filters have been implemented.

See
caplin.grid.GridColumn#addFilter
#clearAllFilters

void clearAllFilters()

Removes all the filters that have been added to the columns within this GridColumnModel.

See
caplin.grid.GridColumn#addFilter
#applyFilters

void clearSort()

Removes any sort currently applied to the grid column model.

Array getActiveColumns()

Returns the list of visible columns.

Columns that are not shown, but that are available to be added, are in a separate list that can be accessed via #getAvailableColumns. When a column is added to list of active columns (using #addColumns it is at the same time removed from the list of available columns. Equally, when a column, or columns, are removed from the list of available columns (using #removeColumns) they are at the same time added to list of available columns.

Array getActiveFilters()

Returns an array of all the currently active column filters.

Returns
An array of caplin.grid.GridColumnFilter instances

Array getAvailableColumns()

Returns the list of columns that are not currently being shown, but are available for addition.

See
#getActiveColumns

caplin.grid.GridColumn getColumnById(String sColumnId)

Returns the column with specified column identifier.

Parameters
String sColumnId the identifier of the column as specified within the XML file used to configure the grid.
Returns
a grid column if one exists with the given name, or null otherwise.

caplin.grid.GridColumn getColumnByIndex(int nColumnIndex)

Returns the column identified by the specified column index. Note - this index is into the currently active (visible) columns.

Parameters
int nColumnIndex the zero based index of the column in the currently active columns.
Returns
a grid column if one exists with the given index in the active view, or null otherwise.

Array getRequiredFields()

Returns the list of fields the data provider must make available so that the columns have all the necesarry information to perform updates.

caplin.grid.GridColumn getSortColumn()

Returns the column that the grid is currently using for sorting.

A grid can only be sorted on one column. If an arbitrary GridColumn has its sort order changed, then any other column that was being used for sorting will have its sort order set to no sorting. If there is currently no sorting applied to the grid, then this method will return null.

Returns
The grid column currently being used for sorting, or null if no sorting is currently applied.
See
caplin.grid.GridColumn#setSortOrder

boolean hasColumnOrderChanged()

Determine whether the column order has changed since the grid was first opened.

void isColumnAvailable(String sColumnId)

Returns true if the column id is a column that is not presently active but could be made active

Parameters
String sColumnId the id of the column from the XML configuration.
Returns
a Boolean

void moveColumn(int nIndex, int nNewIndex)

Moves the column from its present position to a new one. To move to the the very beginning use index zero. To move to the very end use the number of columns.

Parameters
int nIndex Zero based index of the column to move
int nNewIndex Index at which the column will be placed
See
#addColumns
#removeColumns

boolean removeColumnModelListener(caplin.grid.GridColumnModelListener oColumnModelListener)

Removes a column model listener that no longer wishes to observe events fired from this GridColumnModel.

Parameters
caplin.grid.GridColumnModelListener oColumnModelListener The listener to remove.
Returns
true if the listener previously existed, and false otherwise.
See
#addColumnModelListener

void removeColumns(int nStartIndex, int nSize)

Removes a set of columns from the GridColumnModel.

Parameters
int nStartIndex The zero-based index of the first column to be removed.
int nSize The number of columns to remove after the start index.
Throws
caplin.core.Error
If the index is not within the bounds of the current columns within the model.
See
#addColumns
#replaceColumn

void replaceColumn(int nIndex, String sColumnId)

Replaces the column at the specified index with the specified column.

Parameters
int nIndex The index of the column to replace.
String sColumnId The unique identifier of the new column that will replace the existing column at the given index.
Throws
caplin.core.Error
If the column is not an instance of caplin.grid.GridColumn, or if the position is not within the bounds of the current columns within the model.
See
#addColumns
#removeColumns