new Sorting(table) → {FooTable.Sorting}
The sorting component adds a small sort button to specified column headers allowing users to sort those columns in the table.
Parameters:
Name | Type | Description |
---|---|---|
table |
FooTable.Table | The parent FooTable.Table object for the component. |
Returns:
- Type
- FooTable.Sorting
Extends
Members
allowed :boolean
Whether or not to allow sorting to occur, should be set using the
FooTable.Sorting#toggleAllowed
method.
Type:
- boolean
column :FooTable.Column
The current sorted column.
Type:
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:
initial :Object
The initial sort state of the table, this value is used for determining if the sorting has occurred or to reset the state to default.
Type:
- Object
(protected) o :object
This provides a shortcut to the
FooTable.Table#options
.sorting
object.
Type:
- object
Methods
(static) hasChanged() → {boolean}
Checks whether any sorting has occurred for the table.
Returns:
- Type
- boolean
(static) reset()
Resets the table sorting to the initial state recorded in the components init method.
(static) toggleAllowed(stateopt)
Toggles whether or not sorting is currently allowed.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
state |
boolean |
<optional> |
You can optionally specify the state you want it to be, if not supplied the current value is flipped. |
(private) _onSortClicked(e)
Handles the sort button clicked event.
Parameters:
Name | Type | Description |
---|---|---|
e |
jQuery.Event | The event object for the event. |
(private) _sort(column, directionopt) → {jQuery.Promise}
Performs the required steps to handle sorting including the raising of the
FooTable.Sorting#"before.ft.sorting"
and FooTable.Sorting#"after.ft.sorting"
events.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
column |
string | number | FooTable.Column | The column name, index or the actual FooTable.Column object to sort by. |
||
direction |
string |
<optional> |
"ASC" | The direction to sort by, either ASC or DESC. |
Fires:
Returns:
- Type
- jQuery.Promise
(protected) destroy()
Destroys the sorting component removing any UI generated from the table.
- Overrides:
Fires:
(protected) draw()
Updates the sorting UI setting the state of the sort buttons.
- Overrides:
(protected) init()
Initializes the sorting component for the plugin using the supplied table and options.
This:
- Overrides:
Fires:
(protected) postdraw()
This method is called from the
FooTable.Table#draw
method.
- Inherited From:
(protected) predraw()
Performs the actual sorting against the
FooTable.Rows#current
array.
- Overrides:
(protected) preinit(data)
Checks the supplied data and options for the sorting component.
This:
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The jQuery data object from the parent table. |
- Overrides:
Fires:
sort(column, directionopt) → {jQuery.Promise}
Sets the sorting options and calls the
FooTable.Table#draw
method to perform the actual sorting.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
column |
string | number | FooTable.Column | The column name, index or the actual FooTable.Column object to sort by. |
||
direction |
string |
<optional> |
"ASC" | The direction to sort by, either ASC or DESC. |
Fires:
Returns:
- Type
- jQuery.Promise