Class: ColumnSorting

ColumnSorting

This plugin sorts the view by a column (but does not sort the data source!). To enable the plugin, set the
Options#columnSorting property to an object defining the initial sorting order (see the example below).

Example
// as boolean
columnSorting: true

// as a object with initial order (sort ascending column at index 2)
columnSorting: {
 column: 2,
 sortOrder: 'asc', // 'asc' = ascending, 'desc' = descending, 'none' = original order
 sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
}

Members

sortColumnNumber

Physical index of last sorted column.

sortEmptyCellsBoolean

Sorting empty cells.

sortOrderString

Order of last sorting. For asc ascending order, for desc descending order, for none the original order.

Methods

destroy()

Destroys the plugin instance.

disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getNextOrderState(column){String}

Get new order state for particular column. The states queue looks as follows: 'asc' -> 'desc' -> 'none' -> 'asc'

Parameters:
Name Type Description
column Number

Visual column index.

Returns: {String} Sorting order (asc for ascending, desc for descending and none for initial state).

isEnabled(){Boolean}

Checks if the plugin is enabled in the handsontable settings. This method is executed in Hooks#beforeInit
hook and if it returns true than the ColumnSorting#enablePlugin method is called.

Returns: {Boolean}

isSorted(){Boolean}

Checks if any column is in a sorted state.

Returns: {Boolean}

loadSortingState(){*}

Loads the sorting state. To use this method the Options#persistentState option has to be enabled.

Fires:
Returns: {*} Previously saved sorting state.

saveSortingState()

Saves the sorting state. To use this method the Options#persistentState option has to be enabled.

Fires:

sort(column, order)

Sorts the table by chosen column and order.

Parameters:
Name Type Description
column Number

Visual column index.

order String optional

Sorting order (asc for ascending, desc for descending and none for initial state).

Fires: