new Columns(table) → {FooTable.Columns}
The columns class contains all the logic for handling columns.
Parameters:
| Name | Type | Description |
|---|---|---|
table |
FooTable.Table | The parent FooTable.Table this component belongs to. |
Returns:
- Type
- FooTable.Columns
Extends
Members
$header :jQuery
The jQuery header row object.
Type:
array :Array.<FooTable.Column>
An array of
FooTable.Column objects created from parsing the options and/or DOM.
Type:
- Array.<FooTable.Column>
(protected) destroy
This method is called from the
FooTable.Table#destroy method.
- Inherited From:
enabled :boolean
Whether or not this component is enabled. Disabled components only have there preinit method called allowing for this value to be overridden.
Type:
- boolean
- Inherited From:
ft :FooTable.Table
The parent
FooTable.Table for the component.
Type:
- Inherited From:
(protected) o :FooTable.Table#options
This provides a shortcut to the
FooTable.Table#options object.
Type:
- FooTable.Table#options
showHeader :boolean
Whether or not to display the header row.
Type:
- boolean
Methods
(protected) $create()
Creates the header row for the table from the parsed column definitions.
This:
(protected) draw()
Performs the actual drawing of the columns, hiding or displaying them depending on there breakpoints.
This:
- Overrides:
ensure(columns) → {Array.<FooTable.Column>}
Takes an array of column names, index's or actual
FooTable.Column and ensures that an array of only FooTable.Column is returned.
Parameters:
| Name | Type | Description |
|---|---|---|
columns |
Array.<string> | Array.<number> | Array.<FooTable.Column> | The array of column names, index's or FooTable.Column to check. |
Returns:
- Type
- Array.<FooTable.Column>
get(column) → {Array.<FooTable.Column>|FooTable.Column|null}
Attempts to return a
FooTable.Column instance when passed the FooTable.Column instance, the FooTable.Column#name string or the FooTable.Column#index number.
If supplied a function this will return an array by iterating all columns passing the index and column itself to the supplied callback as arguments.
Returning true in the callback will include the column in the result.
Parameters:
| Name | Type | Description |
|---|---|---|
column |
FooTable.Column | string | number | function | The column to retrieve. |
Returns:
The column if one is found otherwise it returns NULL.
- Type
- Array.<FooTable.Column> | FooTable.Column | null
Example
This example shows retrieving a column by name assuming a column called "id" exists. The columns object is an instance of FooTable.Columns.
var column = columns.get('id');
if (column instanceof FooTable.Column){
// found the "id" column
} else {
// no column with a name of "id" exists
}
// to get an array of all hidden columns
var columns = columns.get(function(col){
return col.hidden;
});
(protected) init()
Initializes the columns creating the table header if required.
This:
- Overrides:
Fires:
(protected) parse(data) → {jQuery.Promise}
This parses the columns from either the tables rows or the supplied options.
This:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | The tables jQuery data object. |
Returns:
- Type
- jQuery.Promise
(protected) parseFinalize(deferred, cols)
Used to finalize the parsing of columns it is supplied the parse deferred object which must be resolved with an array of
FooTable.Column objects
or rejected with an error.
Parameters:
| Name | Type | Description |
|---|---|---|
deferred |
jQuery.Deferred | The deferred object used for parsing. |
cols |
Array.<object> | An array of all merged column definitions. |
(protected) postdraw()
This method is called from the
FooTable.Table#draw method.
- Inherited From:
(protected) predraw()
The predraw method called from within the
FooTable.Table#draw method.
This:
- Overrides:
(protected) preinit(data)
The columns preinit method is used to parse and check the column options supplied from both static content and through the constructor.
This:
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | The jQuery data object from the root table element. |
- Overrides: