Constructor
new HTMLTableWrapperListener(table, columnControlFactoryopt, cellInterpreteropt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
table |
HTMLTableElement | HTMLTableWrapper |
|
|
columnControlFactory |
ColumnControlFactory | HTMLTableWrapperListener~getColumnControl |
<optional> |
Optional factory if custom column controls are needed. |
cellInterpreter |
CellInterpreter | HTMLTableWrapperControl~populateCellValues |
<optional> |
Interpreter to use when falling back to the default HTMLTableWrapperControl on calls to HTMLTableWrapperListener#getColumnControl. |
- Implements:
- Source:
Members
(static) processedColumnHeader
Class name added to HTMLTableCellElement
s upon which HTMLTableWrapperListener
instances are registered for
click events. Default value is 'data-table-column-header'
.
- Source:
(private) columnControlFactory :ColumnControlFactory
ColumnControlFactory to use when creating controls.
Type:
- Source:
(private) columnControls :Array.<ColumnControl>
ColumnControl cache.
Type:
- Array.<ColumnControl>
- Source:
(private) dataTable :HTMLTableWrapper
Backing HTMLTableWrapper.
Type:
- Source:
(private) sortDescriptorOrder :Array.<number>
Current column-order in which to apply sort descriptors. Initially null
, initialized on first call to HTMLTableWrapperListener#processTable.
Type:
- Array.<number>
- Source:
(private) tableHeaderCache :Array.<HTMLTableCellElement>
Cache of HTMLTableCellElement
s for which this class is registered for click events.
Type:
- Array.<HTMLTableCellElement>
- Source:
Methods
dispose()
Disposes this HTMLTableWrapperListener
. This HTMLTableWrapperListener
will remove itself as a click listener for any
HTMLTableCellElement
s upon which it has registered itself, as well as remove the HTMLTableWrapperListener.processedColumnHeader
class name. Additionally, if any cached ColumnControls define a dispose function, it will also be called.
- Implements:
- Source:
getColumnControl(columnIndex) → {ColumnControl}
Obtains a ColumnControl for the given columnIndex
. If one is cached (has been obtained before), it will be returned. Otherwise it will be created using the
ColumnControlFactory passed to the constructor of this HTMLTableWrapperListener
. If defined, and its ColumnControlFactory#getColumnControl (or its
direct invocation if a HTMLTableWrapperListener~getColumnControl) function returns a value that is not Nothing, that value will be cached and returned.
Failing that, a new HTMLTableWrapperControl will be cached and returned.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | Index of the column for which a ColumnControl is to be obtained. |
- Source:
Throws:
-
If
columnIndex
is greater than or equal to the number of columns in the backing table. - Type
- RangeError
Returns:
The newly created, or previously cached ColumnControl for the given columnIndex
.
- Type
- ColumnControl
getDataTable() → {HTMLTableWrapper}
Returns this HTMLTableWrapperListener
's backing HTMLTableWrapper.
- Source:
Returns:
This HTMLTableWrapperListener
's backing HTMLTableWrapper.
- Type
- HTMLTableWrapper
getTableHeaderElement(columnIndex) → {HTMLTableCellElement}
Returns the HTMLTableCellElement
acting as the column header for the given columnIndex
.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | Index of the column header to be retrieved. |
- Source:
Throws:
-
If
columnIndex
is greater than or equal to the number of columns in the backing table. - Type
- RangeError
Returns:
The HTMLTableCellElement
acting as the column header for the given columnIndex
.
- Type
- HTMLTableCellElement
handleEvent(event)
Implementation of DOM EventListener
.
Parameters:
Name | Type | Description |
---|---|---|
event |
Event | Event being dispatched. |
- Source:
init()
Initializes this HTMLTableWrapperListener
. This HTMLTableWrapperListener
will be added as a click listener for each HTMLTableCellElement
in the first row of the backing table's header section. The class name HTMLTableWrapperListener.processedColumnHeader will also be added to
each cell.
- Implements:
- Source:
openColumnControl(columnIndex)
Opens the ColumnControl for the given columnIndex
. Delegates to HTMLTableWrapperListener#getColumnControl
to obtain the ColumnControl to be opened. After obtained, ColumnControl#open will be called on it, and
ColumnControl#close on all others in the cache.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | Index of the column upon which a ColumnControl is to be opened. |
- Source:
Throws:
-
If
columnIndex
is greater than or equal to the number of columns in the backing table. - Type
- RangeError
processTable()
Filters and sorts the backing table based upon the state of cached ColumnControls.
The ColumnControl#getFilterDescriptor and ColumnControl#getSortDescriptor functions are called for each
cached ColumnControl in the order they are created. Each result that is not Nothing is stored in a distinct
Array
(one for FilterDescriptors, another for SortDescriptors), and subsequently passed to the backing
HTMLTableWrapper's HTMLTableWrapper#filter and HTMLTableWrapper#sort functions. Filtering is performed before sorting.
SortDescriptors are ordered according to the order in which they are/were returned from this and previous calls. E.g., consider
the following sequence of calls to processTable
:
- A valid SortDescriptor is returned for column 1 => table will be ordered by column 1
- A valid SortDescriptor is returned for columns 1 and 2 => table will be ordered by columns 1, 2
- A valid SortDescriptor is returned for columns 1, 2, and 3 => table will be ordered by columns 1, 2, 3
- A valid SortDescriptor is only returned for columns 2 and 3 => table will be ordered by columns 2, 3
- A valid SortDescriptor is returned for columns 1, 2, and 3 again => table will be ordered by columns 2, 3, 1
- Source:
Type Definitions
getColumnControl(columnIndex, parent) → {ColumnControl}
Called by HTMLTableWrapperListener to obtain a ColumnControl for a given column. If a value is returned, it will be used as the control for that column. If Nothing is returned, the default control (HTMLTableWrapperControl) will be created and used for that column.
Parameters:
Name | Type | Description |
---|---|---|
columnIndex |
number | Column index for which a ColumnControl is needed. |
parent |
HTMLTableWrapperListener | The HTMLTableWrapperListener requesting a control. |
- Source:
Returns:
A ColumnControl if a client-defined control is needed for the given columnIndex
, otherwise Nothing.
- Type
- ColumnControl