@@ -559,8 +559,6 @@ class DataHarmonizer {
559
559
560
560
afterFilter : function ( filters ) {
561
561
// column: 0, conditions: ('cancogen_covid-19', "eq", [], operation: "conjunction"
562
- // Didn't make a difference.
563
- //self.hot.render();
564
562
565
563
} ,
566
564
//beforePaste:
@@ -812,7 +810,7 @@ class DataHarmonizer {
812
810
* header row selection
813
811
*/
814
812
// https://handsontable.com/docs/javascript-data-grid/api/hooks/#afterselection
815
- afterSelectionEnd : ( row , column , row2 , column2 , selectionLayerLevel ) => {
813
+ afterSelectionEnd : ( row , column , row2 , column2 , selectionLayerLevel , action ) => {
816
814
817
815
console . log ( "afterSelectionEnd" , self . schema , row , column , row2 , column2 , selectionLayerLevel )
818
816
@@ -2194,11 +2192,12 @@ class DataHarmonizer {
2194
2192
2195
2193
//}
2196
2194
2197
- //dh.hot.batchRender(() => {
2198
- dh . hot . suspendExecution ( ) ;
2199
- //dh.hot.suspendRender();
2195
+ // Save, deselect, and then set cursor, Otherwise selected cell gets
2196
+ // somehow set to same column but first row after filter!!!
2197
+ let cursor = dh . hot . getSelected ( ) ;
2198
+ dh . hot . deselectCell ( ) ;
2200
2199
2201
- // dh.hot.deselectCell() ; //Otherwise selected cell gets initalized to 1st row !!!
2200
+ dh . hot . suspendExecution ( ) ; // Recommended in handsontable example.
2202
2201
const filtersPlugin = dh . hot . getPlugin ( 'filters' ) ;
2203
2202
2204
2203
filtersPlugin . clearConditions ( ) ;
@@ -2215,9 +2214,23 @@ class DataHarmonizer {
2215
2214
} ) ;
2216
2215
2217
2216
filtersPlugin . filter ( ) ;
2218
- // add sorting: hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' })
2217
+ // Add sorting: hot.getPlugin('columnSorting').sort({ column: 1, sortOrder: 'desc' })
2219
2218
2220
2219
dh . hot . resumeExecution ( ) ;
2220
+
2221
+ setTimeout ( ( ) => { dh . hot . render ( ) ; } , 400 ) ;
2222
+
2223
+ if ( cursor ) {
2224
+ // Adding custom event type to selectCell() call, but so far not using this.
2225
+ cursor [ 0 ] . push ( 'afterFilteriing' ) ;
2226
+ dh . hot . selectCell ( ...cursor [ 0 ] ) ;
2227
+ // Note this will cause a "double event" of selecting same cell twice.
2228
+
2229
+ }
2230
+
2231
+ // filtersPlugin continues activity AFTER returning, leading to rendering
2232
+ // not reflecting filtering work. So we have to trigger a delayed render
2233
+ //setTimeout(() => { dh.hot.render(); }, 500);
2221
2234
2222
2235
return true
2223
2236
}
0 commit comments