# Class: Columns

## FooTable.Columns

#### 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

- FooTable.Component

### Members

#### $header :jQuery

The jQuery header row object.

##### Type:

- jQuery

#### 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:
  - FooTable.Component#destroy

#### 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:
  - FooTable.Component#enabled

#### ft :FooTable.Table

The parent `FooTable.Table` for the component.

##### Type:

- FooTable.Table

Inherited From:
  - FooTable.Component#ft

#### (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:

- FooTable.Columns

#### (protected) draw()

Performs the actual drawing of the columns, hiding or displaying them depending on there breakpoints.

##### This:

- FooTable.Columns

Overrides:
  - FooTable.Component#draw

#### 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 columnsvar columns = columns.get(function(col){ return col.hidden;});

#### (protected) init()

Initializes the columns creating the table header if required.

##### This:

- FooTable.Columns

Overrides:
  - FooTable.Component#init

##### Fires:

- FooTable.event:Columns"init.ft.columns"

#### (protected) parse(data) → {jQuery.Promise}

This parses the columns from either the tables rows or the supplied options.

##### This:

- FooTable.Columns

##### 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` objectsor 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:
  - FooTable.Component#postdraw

#### (protected) predraw()

The predraw method called from within the `FooTable.Table#draw` method.

##### This:

- FooTable.Columns

Overrides:
  - FooTable.Component#predraw

#### (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:

- FooTable.Columns

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | object | The jQuery data object from the root table element.

Overrides:
  - FooTable.Component#preinit