handsontable icon indicating copy to clipboard operation
handsontable copied to clipboard

Get current viewport in v14.5.0

Open conschtek opened this issue 1 year ago • 2 comments

Describe the bug

Hi, I've discovered an issue after upgrading to v14.5.0. I'd like to keep the viewport before updating the data, so I save the viewport by using the getFirstVisibleColumn/getFirstVisibleRow and after the update is finished I set the saved values back by using scrollViewportTo.

It still works just fine, when there are no merged cells. However, in the case of a merged cell reaching from column 0 to column 100 the getLastVisibleRow/getLastVisibleColumn returns incorrect values (see example below). Same for getFirstVisibleColumn/getFirstVisibleRow when you're scrolling. getFirstVisibleRow returns in every case 0.

Video/Screenshots

No response

Provide a link to the demo with the bug reproduction

https://jsfiddle.net/TSchrempf/n7gzhky2/30/

Handsontable version

14.5.0

Framework version

No response

Your environment

macOS and Chrome

conschtek avatar Aug 09 '24 11:08 conschtek

Hi @conschtek

Thank you for the message, and sorry for the confusion (I'd request to add this detail to the docs).

Merge area is extending column virtualization, so the getLastVisibleColumn will return the last column index from the merged area.

If you'd like to get the actual value, you may want to use private instance.view methods. It is not recommended (as it's private), but if you'd like to have it working now, that might be the only option.

Here's an updated demo https://jsfiddle.net/b5dmtnuy/

AMBudnik avatar Aug 09 '24 11:08 AMBudnik

Hi @AMBudnik

Thank you for your quick answer and workaround! It works just fine.

conschtek avatar Aug 13 '24 07:08 conschtek

Hi @AMBudnik, I am also having issues with getLastVisibleRow since 14.5.0. Regarding your workaround, is there a reliable way to get the first and last visible rows in the future, since you say the workaround is not recommended?

micahbf avatar Oct 23 '24 19:10 micahbf

Hi @micahbf

are you looking for a getLastVisibleRow in general, or do you also use merged cells within a larger rowspan applied? If you could share any examples/drafts that would be helpful.

AMBudnik avatar Oct 24 '24 06:10 AMBudnik