Hi
I have noticed that a SetState within a context menu function causes the table to reload, which resets any column sorts that have been applied.
I’m using react 17.0.2 with HandsOnTable 7.4.2.
The table is initialised with a function called HotSettings() which is referenced in the render section by the HotTable like so
< HotTable
ref={this.hotTableComponent}
id={this.id}
settings={this.hotSettings()}
/>
The context menu setup looks like this:
return {
items: {
Rows: {
// Own custom option
name: “Row…”,
callback: function (key, selection, clickEvent) {
const selectRows = this.selectRows;
setTimeout(function () {
const start = selection[0].start;
selectRows(start.row, start.row);
visualiserShow();
}, 300);
},
}
The function visualiserShow() above contains a SetState, and when it is hit it causes the Table to load again, something demonstrated by the presence of a console.log in the HotSettings() function. The reloading the table causes it to reset and clears all sorts. The purpose of the context menu is to load a modal which contains analysis tools for the selected row.
Is there a way round this?
A bit of background on the above code:
- I reported a similar problem when a setState is used an a code hook in this thread and was advised that downgrading to version 7.4.2 would fix this in this thread.
- I’m using the SetTimeout function in the context menu to deal with a problem described in this thread.
Andy