Handsontable 6.0.0 with multi-column sorting

Peter Plesa Release Notes / September 27, 2018

Handsontable 6.0.0 with multi-column sorting

Today we’ve released v6.0.0 of Handsontable (CE/Pro). The Pro version features a brand new plugin, multi-column sorting, and its addition influenced multiple changes related to the UI and API. Regarding the former, we’ve replaced our old sorting indicators with new ones that more clearly identify whether data is being sorted in ascending or descending order (and they’re prettier too!). Naturally, we’ve also included numbers to indicate the sequence of the columns involved in the multi-column sort.

When it comes to the API, the columnSorting plugin was refactored to, well, make life easier for all of us. One of the changes is that the sort method in the plugin was reorganized. It’s now a pure function, so every call to it will set an entirely new sort order. Also, three new public API methods were added (getSortConfig, setSortConfig, and clearSort), while three others were rewritten, renamed, and set as private (getNextOrderState, loadSortingState, and saveSortingState).

One more change to mention regards the action of sorting a column by clicking on its header. Now, using the headerAction option, it is possible to disable this behaviour. For the rest of the details, check out the list below.

Breaking changes

  • We refactored and rewrote parts of the columnSorting plugin in order for it to work seamlessly with the new multiColumnSorting plugin for Handsontable Pro. This allowed us to fix multiple problems that the previous version of the plugin had. This introduced some backward-incompatible changes:
    • The configuration items (such as sortIndicatorsortEmptyCellssortFunction) for the plugin were moved into the scope of the plugin config.
    • The initial plugin configuration is stored under the initialConfig property in the plugin configuration.
    • The sortFunction config item was renamed to compareFunctionFactory and converted to a factory returning a compare function (and moved into the plugin configuration scope, as mentioned above).
    • The sortIndicator config item was renamed to indicator (and moved into the plugin configuration scope, as mentioned above).
    • Comparator function structure changed:
    
    // Was:
     function numericSort(sortOrder, columnMeta) {
     	return function ([, value], [, nextValue]) {
    
     // Is:
     function numericSort(sortOrder, columnMeta) {
     	return function (value, nextValue) {
    
    • The sort method arguments were reorganized, so it accepts the sorting configuration as an object:
    
    hot.getPlugin('columnSorting').sort({ column: 0, sortOrder: 'asc' });
    
    • Some public methods were rewritten, renamed and set as private, namely:
      • getNextOrderState
      • loadSortingState
      • saveSortingState
    • The beforeColumnSort and afterColumnSort hooks receive a different set of arguments. For more information, check our documentation.
    • Calling the updateSettings method with columnSorting defined will set a fresh sort configuration.

Changes

Apart from the breaking changes above, this release introduces some additional changes to the sorting plugin:

  • Added a new plugin – multiColumnSorting. It allows multiple columns to be used when sorting the table. While it works similarly to CE’s columnSorting, it introduces multiple new functionalities. Detailed information about this new feature can be found in the documentation and in the description of pull request #101. Regarding the changes to columnSorting, detailed information can be found in the description of pull request #5411 as well as in the documentation.
  • Replaced the sorting indicators with new ones, in the form of arrows.
  • The sorting indicators are now displayed by default.
  • Added the possibility to disable the “sort-by-header click” action, using the headerAction option.

Follow us on Twitter to keep up with news and updates.

Leave a comment below or write to us if you have any questions.