Skip to content

Methods

clearSort

Source code

multiColumnSorting.clearSort()

Clear the sort performed on the table.

disablePlugin

Source code

multiColumnSorting.disablePlugin()

Disables the plugin functionality for this Handsontable instance.

enablePlugin

Source code

multiColumnSorting.enablePlugin()

Enables the plugin functionality for this Handsontable instance.

getSortConfig

Source code

multiColumnSorting.getSortConfig([column]) ⇒ undefined | object | Array

Get sort configuration for particular column or for all sorted columns. Objects contain column and sortOrder properties.

Note: Please keep in mind that returned objects expose visual column index under the column key. They are handled by the sort function.

ParamTypeDescription
[column]numberoptional Visual column index.

isEnabled

Source code

multiColumnSorting.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 then the MultiColumnSorting#enablePlugin method is called. When [[Options#dataProvider]] is a complete server-backed configuration, the DataProvider plugin blocks this plugin from enabling.

isSorted

Source code

multiColumnSorting.isSorted() ⇒ boolean

Checks if the table is sorted (any column have to be sorted).

setSortConfig

Source code

multiColumnSorting.setSortConfig(sortConfig)

Warn: Useful mainly for providing server side sort implementation (see in the example below). It doesn’t sort the data set. It just sets sort configuration for all sorted columns. Note: Please keep in mind that this method doesn’t re-render the table.

Example

beforeColumnSort: function(currentSortConfig, destinationSortConfigs) {
const columnSortPlugin = this.getPlugin('multiColumnSorting');
columnSortPlugin.setSortConfig(destinationSortConfigs);
// const newData = ... // Calculated data set, ie. from an AJAX call.
this.updateData(newData); // Update data set and re-render the table.
return false; // The blockade for the default sort action.
}
ParamTypeDescription
sortConfigundefined
object
Array
Single column sort configuration or full sort configuration (for all sorted columns). The configuration object contains column and sortOrder properties. First of them contains visual column index, the second one contains sort order (asc for ascending, desc for descending).

sort

Source code

multiColumnSorting.sort(sortConfig)

Sorts the table by chosen columns and orders.

Emits: Hooks#event:beforeColumnSort, Hooks#event:afterColumnSort
Example

// sort ascending first visual column
hot.getPlugin('multiColumnSorting').sort({ column: 0, sortOrder: 'asc' });
// sort first two visual column in the defined sequence
hot.getPlugin('multiColumnSorting').sort([{
column: 1, sortOrder: 'asc'
}, {
column: 0, sortOrder: 'desc'
}]);
ParamTypeDescription
sortConfigundefined
object
Array
Single column sort configuration or full sort configuration (for all sorted columns). The configuration object contains column and sortOrder properties. First of them contains visual column index, the second one contains sort order (asc for ascending, desc for descending). Note: Please keep in mind that every call of sort function set an entirely new sort order. Previous sort configs aren’t preserved.