Class: ColumnSorting

ColumnSorting

handsontable/src/plugins/columnSorting/columnSorting.js, line 44

This plugin sorts the view by a column (but does not sort the data source!).
To enable the plugin, set the columnSorting property to either:

  • a boolean value (true/false),
  • 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: true, // true = ascending, false = descending, undefined = original order
 sortEmptyCells: true // true = the table sorts empty cells, false = the table moves all empty cells to the end of the table
}
...

Methods

handsontable/src/plugins/columnSorting/columnSorting.js, line 323

dateSort(sortOrder, columnMeta){function}

Date sorting algorithm

Parameters:
Name Type Description
sortOrder Boolean

Sorting order (true for ascending, false for descending).

columnMeta Object

Column meta object.

Returns: {function} The compare function.
handsontable/src/plugins/columnSorting/columnSorting.js, line 260

defaultSort(sortOrder, columnMeta){function}

Default sorting algorithm.

Parameters:
Name Type Description
sortOrder Boolean

Sorting order - true for ascending, false for descending.

columnMeta Object

Column meta object.

Returns: {function} The comparing function.
handsontable/src/plugins/columnSorting/columnSorting.js, line 115

disablePlugin()

Disable plugin for this Handsontable instance.

handsontable/src/plugins/columnSorting/columnSorting.js, line 65

enablePlugin()

Enable plugin for this Handsontable instance.

handsontable/src/plugins/columnSorting/columnSorting.js, line 58

isEnabled(){Boolean}

Check if the plugin is enabled in the handsontable settings.

Returns: {Boolean}
handsontable/src/plugins/columnSorting/columnSorting.js, line 566

isSorted(){Boolean}

Check if any column is in a sorted state.

Returns: {Boolean}
handsontable/src/plugins/columnSorting/columnSorting.js, line 220

loadSortingState(){*}

Load the sorting state.

Returns: {*} Previously saved sorting state.
handsontable/src/plugins/columnSorting/columnSorting.js, line 381

numericSort(sortOrder, columnMeta){function}

Numeric sorting algorithm.

Parameters:
Name Type Description
sortOrder Boolean

Sorting order (true for ascending, false for descending).

columnMeta Object

Column meta object.

Returns: {function} The compare function.
handsontable/src/plugins/columnSorting/columnSorting.js, line 198

saveSortingState()

Save the sorting state

handsontable/src/plugins/columnSorting/columnSorting.js, line 154

setSortingColumn(col, order)

Set sorted column and order info

Parameters:
Name Type Description
col number

Sorted column index.

order boolean | undefined

Sorting order (true for ascending, false for descending).

handsontable/src/plugins/columnSorting/columnSorting.js, line 424

sort()

Perform the sorting.

handsontable/src/plugins/columnSorting/columnSorting.js, line 497

translateRow(row){Number}

modifyRow hook callback. Translates physical row index to the sorted row index.

Parameters:
Name Type Description
row Number

Row index.

Returns: {Number} Sorted row index.
handsontable/src/plugins/columnSorting/columnSorting.js, line 511

untranslateRow(row){number}

Translates sorted row index to physical row index.

Parameters:
Name Type Description
row Number

Sorted row index.

Returns: {number} Physical row index.
handsontable/src/plugins/columnSorting/columnSorting.js, line 230

updateOrderClass()

Update sorting class name state.

handsontable/src/plugins/columnSorting/columnSorting.js, line 482

updateSortIndicator()

Update indicator states.