Constructor
new module:ct-grid /Grid Column Model()
Constructs a GridColumnModel
instance —
end-users will never need to do this themselves since grids are fully
constructed based on their XML definition files by the
module:ct-grid/GridComponentFactory
class.
Methods
add Column Model Listener(column Model Listener)
Adds a column model listener that wishes to observe events fired from this
GridColumnModel
.
Parameters:
Name | Type | Description |
---|---|---|
columnModelListener |
module:ct-grid |
The listener to add. |
Throws:
-
If the specified column model listener is not an instance of
module:ct-grid/GridColumnModelListener
. - Type
-
module:br
/Errors .Invalid Parameters Error
add Columns(column Identifiers, start Index) → {Array}
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:
Name | Type | Description |
---|---|---|
columnIdentifiers |
Array | The unique identifiers of the columns to be added to the model. |
startIndex |
int | The zero-based start index where the columns should be added. |
- See:
Throws:
-
If any column is not an instance of
module:ct-grid/GridColumn
, or if the position is not within the bounds of the current columns within the model. - Type
-
module:br
/Errors .Invalid Parameters Error
Returns:
Any columns that could not be added to the model.
- Type
- Array
apply Filters()
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
module:ct-grid/GridColumnModelListener#onFiltersChanged
callback
method will need to fire as each change happens, whereas the application of
filters so that it affects the module:ct-grid/GridDataProvider
responsible for fetching the data may not happen until some later point,
depending on how the module:ct-grid/decorator/GridDecorator
instance(s) used to add these filters have been implemented.
clear All Filters()
Removes all the filters that have been added to the columns within this
GridColumnModel
.
clear Sort()
Removes any sort currently applied to the grid column model.
get Active Columns()
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
module:ct-grid/GridColumnModel#getAvailableColumns
. When a column is
added to list of active columns (using
module:ct-grid/GridColumnModel#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
module:ct-grid/GridColumnModel#removeColumns
) they are at the same
time added to list of available columns.
get Active Filters() → {Array}
Returns an array of all the currently active column filters.
Returns:
An array of module:ct-grid/GridColumnFilter
instances
- Type
- Array
get Available Columns()
Returns the list of columns that are not currently being shown, but are available for addition.
get Column ById(column Id) → {module:ct-grid /Grid Column}
Returns the column with specified column identifier.
Parameters:
Name | Type | Description |
---|---|---|
columnId |
String | 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.
get Column ByIndex(column Index) → {module:ct-grid /Grid Column}
Returns the column identified by the specified column index.
Note - this index is into the currently active (visible) columns.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
int | 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.
get Grid Row Model() → {module:ct-grid /Grid Row Model}
Returns:
get Required Fields()
Returns the list of fields the data provider must make available so that the columns have all the necessary information to perform updates.
get Sort Column() → {module:ct-grid /Grid Column}
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.
has Column Order Changed()
Determine whether the column order has changed since the grid was first opened.
is Column Available(column Id) → {boolean}
Returns true if the column id is a column that is not presently active but could be made active
Parameters:
Name | Type | Description |
---|---|---|
columnId |
String | the id of the column from the XML configuration. |
Returns:
- Type
- boolean
move Column(curr Column Index, new Column Index)
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:
Name | Type | Description |
---|---|---|
currColumnIndex |
int | Zero based index of the column to move |
newColumnIndex |
int | Index at which the column will be placed |
remove Column Model Listener(column Model Listener) → {boolean}
Removes a column model listener that no longer wishes to observe events fired
from this GridColumnModel
.
Parameters:
Name | Type | Description |
---|---|---|
columnModelListener |
module:ct-grid |
The listener to remove. |
Returns:
true
if the listener previously existed, and
false
otherwise.
- Type
- boolean
remove Columns(start Index, column Count)
Removes a set of columns from the GridColumnModel
.
Parameters:
Name | Type | Description |
---|---|---|
startIndex |
int | The zero-based index of the first column to be removed. |
columnCount |
int | The number of columns to remove after the start index. |
Throws:
-
If the index is not within the bounds of the current columns within the model.
- Type
-
module:br
/Errors .Invalid Parameters Error
replace Column(column Index, column Id)
Replaces the column at the specified index with the specified column.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
int | The index of the column to replace. |
columnId |
String | The unique identifier of the new column that will replace the existing column at the given index. |
Throws:
-
If the column is not an instance of
module:ct-grid/GridColumn
, or if the position is not within the bounds of the current columns within the model. - Type
-
module:br
/Errors .Invalid Parameters Error