# Class: Table

## FooTable.Table

#### new Table(element, options, readyopt) → {FooTable.Table}

This class is the core of the plugin and drives the logic of all components.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`element` | HTMLTableElement | jQuery |  | The element or jQuery table object to bind the plugin to.
`options` | object |  | The options to initialize the plugin with.
`ready` | function | <optional> | A callback function to execute once the plugin is initialized.

##### Returns:

Type
  FooTable.Table

### Extends

- FooTable.Class

### Members

#### $el :jQuery

The jQuery table object the plugin is bound to.

##### Type:

- jQuery

#### (private, nullable) _resizeTimeout :number

The timeout ID for the resize event.

##### Type:

- number

#### breakpoints :FooTable.Breakpoints

The breakpoints component for this instance of the plugin.

##### Type:

- FooTable.Breakpoints

#### (protected) classes :Array.<string>

An array of all CSS classes on the table that do not start with "footable".

##### Type:

- Array.<string>

#### columns :FooTable.Columns

The columns component for this instance of the plugin.

##### Type:

- FooTable.Columns

#### (protected) components :object

All components for this instance of the plugin. These are executed in the order they appear in the array for the initialize phase and in reverse order for the destroy phase of the plugin.

##### Type:

- object

##### Properties:

Name | Type | Description
--- | --- | ---
`internal` | Array.<FooTable.Component> | The internal components for the plugin. These are executed either before all other components in the initialize phase or after them in the destroy phase of the plugin.
`core` | Array.<FooTable.Component> | The core components for the plugin. These are executed either after the internal components in the initialize phase or before them in the destroy phase of the plugin.
`custom` | Array.<FooTable.Component> | The custom components for the plugin. These are executed either after the core components in the initialize phase or before them in the destroy phase of the plugin.

#### id :number

The ID of the FooTable instance.

##### Type:

- number

#### initialized :boolean

Whether or not the plugin and all components and add-ons are fully initialized.

##### Type:

- boolean

#### o :object

The options for the plugin. This is a merge of user defined options and the default options.

##### Type:

- object

#### rows :FooTable.Rows

The rows component for this instance of the plugin.

##### Type:

- FooTable.Rows

### Methods

#### (private) _construct(readyopt) → {jQuery.Promise}

Once all properties are set this performs the actual initialization of the plugin calling the `FooTable.Table#_preinit` and`FooTable.Table#_init` methods as well as raising the `FooTable.Table#"ready.ft.table"` event.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`ready` | function | <optional> | A callback function to execute once the plugin is initialized.

##### Fires:

- FooTable.event:Table"ready.ft.table"

##### Returns:

Type
  jQuery.Promise

#### (private) _execute(components, methodName, param1opt, …paramNopt) → {jQuery.Promise}

Executes the specified method with the optional number of parameters on all supplied components waiting for the result of each before executing the next.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`components` | Array.<FooTable.Component> |  | The components to call the method on.
`methodName` | string |  | The name of the method to execute
`param1` | * | <optional> | The first parameter for the method.
`paramN` | * | <optional> <repeatable> | Any additional parameters for the method.

##### Returns:

Type
  jQuery.Promise

#### (private) _init() → {jQuery.Promise}

Initializes this instance of the plugin and calls the callback function if one is supplied once complete.

##### This:

- FooTable.Table

##### Fires:

- FooTable.event:Table"init.ft.table"

##### Returns:

Type
  jQuery.Promise

#### (private) _onWindowResize()

Listens to the window resize event and performs a check to see if the breakpoint has changed.

##### This:

- window

##### Fires:

- FooTable.event:Table"resize.ft.table"

#### (private) _preinit() → {jQuery.Promise}

The preinit method is called prior to the plugins actual initialization and provides itself and it's components an opportunity to parse any additional option values.

##### Fires:

- FooTable.event:Table"preinit.ft.table"

##### Returns:

Type
  jQuery.Promise

#### destroy()

Destroys this plugin removing it from the table.

##### This:

- FooTable.Table

##### Fires:

- FooTable.event:Table"destroy.ft.table"

#### (protected) draw() → {jQuery.Promise}

Performs the drawing of the table.

##### This:

- FooTable.Table

##### Fires:

- FooTable.event:Table"predraw.ft.table"
- FooTable.event:Table"draw.ft.table"
- FooTable.event:Table"postdraw.ft.table"

##### Returns:

Type
  jQuery.Promise

#### (protected) execute(reverse, enabled, methodName, param1opt, …paramNopt) → {jQuery.Promise}

Executes the specified method with the optional number of parameters on all components and waits for the promise from each to be resolved before executing the next.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`reverse` | boolean |  | Whether or not to execute the component methods in the reverse order to what they were registered in.
`enabled` | boolean |  | Whether or not to execute the method on enabled components only.
`methodName` | string |  | The name of the method to execute.
`param1` | * | <optional> | The first parameter for the method.
`paramN` | * | <optional> <repeatable> | Any number of additional parameters for the method.

##### Returns:

Type
  jQuery.Promise

#### raise(eventName, argsopt) → {jQuery.Event}

Raises an event on this instance supplying the args array as additional parameters to the handlers.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`eventName` | string |  | The name of the event to raise, this can include namespaces.
`args` | Array | <optional> | An array containing additional parameters to be passed to any bound handlers.

##### Returns:

Type
  jQuery.Event

#### use(type) → {*|null}

Attempts to retrieve the instance of the supplied component type for this instance.

##### This:

- FooTable.Table

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | object | The content type to retrieve for this instance.

##### Returns:

Type
  * | null