I just noticed that the problem might be related to how soon after ‘render’ the reference is set.
so ref={this.setHotTableRef} seems to happen after afterRender={() => this.test()}, so when i try to access my reference to the HotTable within my test function, it is null.
So, our columns are basically referenced like ‘apr0’, ‘feb0’, etc. Then when i try either scrollViewportTo, or selectCell, neither of them scroll vertically to my column. I tested and noticed that the scroll works if i set the column manually to an integer.
My question is, how can i convert ‘apr0’ to its equivalent actual column number? I tried both toPhysicalColumn and toVisualColumn and both simply return me the same string i pass.
I was hoping then that hotInstance.toVisualColumn(‘apr0’) would return 5 for example.
If I use scrollViewportTo, it scrolls to the expected position, but it doesnt select my cell. And if i use selectCell instead, it scrolls and selects the cell, BUT it doesnt have the snaptocell property that scrollViewportTo uses. So at the moment, im forced to do this:
I still have to scroll horizontally to the right position, then this event would fire, and inside of it i would put selectCell. Correct me if im wrong.
A side question if i may: How can i set the focus back on the grid ? I’m able now to select the cell in question and scroll to it, but the grid is not focused, so the user has to actually use the mouse to get focus again. I tried searching for Handsontable events for this but couldnt find any,
We usually use the selectCell() to add a focus to the table. And when it comes to this method this solution Handsontable example - JSFiddle - Code Playground doesn’t meet your requirements? Sorry if I’m missing something.
For some reason my grid doesnt get focus. Using the example of code I sent, selectCell is in indeed highlighting the cell, but if I try to type right away, the cell doesnt have the actual focus. I’m forced to click with the mouse on it.
I’ll create a video and upload it.
My app is a bit complex for me to create a working demo.
It looks like something can steal the keydown event. You can check if anything in your app uses the keydown event? Also please let me know if you’re using the latest version of Handsontable PRO or older.