Bug with dynamic header and sorting

Tags: #<Tag:0x00007f8b1df78820>

Hey,

yesterday i update to the 6.1.1 version and after the update if have a problem with dynamic headers and sorting. The workflow is: at first i get the table-seetings information with some headers from the server after this i start a request to get the tableData and extend the headers( for example from 4 headers to 6 headers) and if the sorting activ tahn i get following error:
Cannot read property ‘indicator’ of undefined
at ColumnSorting.onAfterGetColHeader (handsontable.js:46852)
at Core. (handsontable.js:46196)
at Hooks.run (handsontable.js:5449)
at Core.runHooks (handsontable.js:17776)
at TableView.appendColHeader (handsontable.js:41444)
at Array. (handsontable.js:41028)
at TableRenderer.renderColumnHeader (handsontable.js:25813)
at TableRenderer.renderColumnHeaders (handsontable.js:25721)
at TableRenderer.render (handsontable.js:25237)
at Table._doDraw (handsontable.js:24675)

I hope u can help me

Over more tests I found the problem, the problem that the columnsettings in the sortplugin dont set the sortcolumn object of my last dynamic header, but i dont know why because my headers the sortcolumns object in the seetings

Thank you for sharing the description.

I will check it out on Monday

Hi @sebastian.rupprecht

the changes has been made in v 6.0.0 (RN)

The configuration items (such as sortIndicator, sortEmptyCells, sortFunction) for the plugin were moved into the scope of the plugin config.

Can you share more information about the second (new) issue?

Hi Aleksandra,

I too am experiencing an issue similar to this, except for being in the pro version

TypeError: Cannot read property 'indicator' of undefined
    at ColumnSorting.onAfterGetColHeader (handsontable.full.js:75551)
    at Core.<anonymous> (handsontable.full.js:74892)
    at Hooks.run (handsontable.full.js:5449)
    at Core.runHooks (handsontable.full.js:38751)
    at TableView.appendColHeader (handsontable.full.js:70140)
    at GhostTable.addColumn (handsontable.full.js:39030)
    at handsontable.full.js:72775
    at arrayEach (handsontable.full.js:290)
    at handsontable.full.js:72770
    at rangeEach (handsontable.full.js:1968)

I am busy trying to track down exactly what is causing this problem. Prior to version 6 there was no problem. Version 3.0.0 works fine.

For me the problem appears when the table increases in the number of columns from say 24 columns to 50.
From column 25 to 50 an exception as above is thrown.

My temporary workaround for the problem is the following: (as pluginSettingsForColumn is undefined for columns 25 to 50)

   /**
 * Callback for the `onAfterGetColHeader` hook. Adds column sorting CSS classes.
 *
 * @private
 * @param {Number} column Visual column index.
 * @param {Element} TH TH HTML element.
 */

  }, {
key: 'onAfterGetColHeader',
value: function onAfterGetColHeader(column, TH) {
  var headerSpanElement = (0, _utils.getHeaderSpanElement)(TH);

  if ((0, _utils.isFirstLevelColumnHeader)(column, TH) === false || headerSpanElement === null) {
    return;
  }

  var physicalColumn = this.hot.toPhysicalColumn(column);
  var pluginSettingsForColumn = this.getFirstCellSettings(physicalColumn).columnSorting;
  var showSortIndicator = pluginSettingsForColumn ? pluginSettingsForColumn.indicator : false;
  var headerActionEnabled = pluginSettingsForColumn ? pluginSettingsForColumn.headerAction : false;

  (0, _element.removeClass)(headerSpanElement, this.domHelper.getRemovedClasses(headerSpanElement));
  (0, _element.addClass)(headerSpanElement, this.domHelper.getAddedClasses(physicalColumn, showSortIndicator, headerActionEnabled));
}

Hi @srichardson

Please share a demo where this issue can be replicable. I will test it and share my thoughts.

Bug can be reproduced with the following JSFilddle.

http://jsfiddle.net/stuartrichardson/usgopkwc/

Make sure you have the console open to see the error.

Regards
Stuart

I recommend using alter method instead http://jsfiddle.net/ae4ng0m9/
You won’t get the error.