# Class: Paging

## FooTable.Paging

#### new Paging(table) → {FooTable.Filtering}

The paging component adds a pagination control to the table allowing users to navigate table rows via pages.

##### Parameters:

Name | Type | Description
--- | --- | ---
`table` | FooTable.Table | The parent `FooTable.Table` object for the component.

##### Returns:

Type
  FooTable.Filtering

### Extends

- FooTable.Component

### Members

#### $cell :jQuery

The jQuery cell object that contains the pagination control and total count.

##### Type:

- jQuery

#### $count :jQuery

The jQuery object that contains the row count.

##### Type:

- jQuery

#### $pagination :jQuery

The jQuery object that contains the links for the pagination control.

##### Type:

- jQuery

#### $row :jQuery

The jQuery row object that contains all the paging specific elements.

##### Type:

- jQuery

#### (private) _previous :number

A number indicating the previous page displayed.

##### Type:

- number

#### (private) _total :number

Used to hold the number of rows in the `FooTable.Rows#array` before paging is applied.

##### Type:

- number

#### countFormat :string

The format string used to generate the text displayed under the pagination control.

##### Type:

- string

#### current :number

The current page number to display.

##### Type:

- number

#### detached :boolean

Whether or not the pagination row is detached from the table.

##### Type:

- boolean

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

#### limit :number

The maximum number of page links to display at once.

##### Type:

- number

#### position :string

The position of the pagination control within the paging rows cell.

##### Type:

- string

#### size :number

The number of rows to display per page.

##### Type:

- number

#### strings :Object

An object containing the strings used by the paging buttons.

##### Type:

- Object

#### total :number

The total number of pages.

##### Type:

- number

### Methods

#### (private, static) _setCount(currentPage, totalPages, pageFirst, pageLast, totalRows)

Uses the countFormat option to generate the text using the supplied parameters.

##### Parameters:

Name | Type | Description
--- | --- | ---
`currentPage` | number | The current page.
`totalPages` | number | The total number of pages.
`pageFirst` | number | The first row number of the current page.
`pageLast` | number | The last row number of the current page.
`totalRows` | number | The total number of rows.

#### (protected) $create()

Creates the paging UI from the current options setting the various jQuery properties of this component.

#### (private) _createLinks()

Creates the pagination links using the current state of the plugin. If the total number of pages is the same asthe last time this function was executed it does nothing.

#### (private) _onPageClicked(e)

Handles the click event for all links in the pagination control.

##### Parameters:

Name | Type | Description
--- | --- | ---
`e` | jQuery.Event | The event object for the event.

#### (private) _set(page) → {jQuery.Promise}

Performs the required steps to handle paging including the raising of the `FooTable.Paging#"before.ft.paging"` and `FooTable.Paging#"after.ft.paging"` events.

##### Parameters:

Name | Type | Description
--- | --- | ---
`page` | number | The page to set.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### (private) _setNavigation(active)

Sets the state for the navigation links of the pagination control and optionally sets the active class state on the current page link.

##### Parameters:

Name | Type | Description
--- | --- | ---
`active` | boolean | Whether or not to set the active class state on the individual page links.

#### (private) _setVisible(page, right)

Sets the visible page using the supplied parameters.

##### Parameters:

Name | Type | Description
--- | --- | ---
`page` | number | The page to make visible.
`right` | boolean | If set to true the supplied page will be the right most visible pagination link.

#### (protected) destroy()

Destroys the paging component removing any UI generated from the table.

Overrides:
  - FooTable.Component#destroy

##### Fires:

- FooTable.event:Paging"destroy.ft.paging"

#### (protected) draw()

Updates the paging UI setting the state of the pagination control.

Overrides:
  - FooTable.Component#draw

#### first() → {jQuery.Promise}

Pages to the first page.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### goto(page) → {jQuery.Promise}

Pages to the specified page.

##### Parameters:

Name | Type | Description
--- | --- | ---
`page` | number | The page number to go to.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### (protected) init()

Initializes the paging component for the plugin using the supplied table and options.

Overrides:
  - FooTable.Component#init

##### Fires:

- FooTable.event:Paging"init.ft.paging"

#### last() → {jQuery.Promise}

Pages to the last page.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### next() → {jQuery.Promise}

Pages to the next page.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### nextPages()

Shows the next X number of pages in the pagination control where X is the value set by the `FooTable.Defaults#paging` - limit option value.

#### pageSize(valueopt) → {number|undefined}

Gets or sets the current page size

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`value` | number | <optional> | The new page size to use.

##### Returns:

Type
  number | undefined

#### (protected) postdraw()

This method is called from the `FooTable.Table#draw` method.

Inherited From:
  - FooTable.Component#postdraw

#### (protected) predraw()

Performs the actual paging against the `FooTable.Rows#current` array removing all rows that are not on the current visible page.

Overrides:
  - FooTable.Component#predraw

#### (protected) preinit(data)

Checks the supplied data and options for the paging component.

##### Parameters:

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

Overrides:
  - FooTable.Component#preinit

##### Fires:

- FooTable.event:Paging"preinit.ft.paging"

#### prev() → {jQuery.Promise}

Pages to the previous page.

##### Fires:

- FooTable.event:Paging"before.ft.paging"
- FooTable.event:Paging"after.ft.paging"

##### Returns:

Type
  jQuery.Promise

#### prevPages()

Shows the previous X number of pages in the pagination control where X is the value set by the `FooTable.Defaults#paging` - limit option value.