Is there a way to reference current viewport and select its last column cell programatically

Tags: #<Tag:0x00007f8b1ce74420>

Hi,

We are dealing with a requirement where we need to programmatically select/click any cell of the last column of the current viewport, which should take effect anytime the screen is scrolled and viewport is updated.

Is there any way we can do the following-
1) Reference current viewport
2) Reference any cell of the last column of current viewport
3) Programmatically select/click the cell referenced in point # 2

This issue is related to viewport not being updated and all columns not being displayed when a horizontal scroll is performed on an ipad. Following are some of the discussion forums on this topic -



We cannot set “viewportColumnRenderingOffset” to max number of columns, since this is impacting the performance heavily.

Please let us know.

Thanks,
Polaris Team.

Hi @ap1

Please find the answers below

1) Reference current viewport
I am not sure how to answer this question. As I assume is a general question that is parted below into 2 points?

2) Reference any cell of the last column of current viewport
Yes, there s a method called getLastVisibleColumn. Here’s a working demo http://jsfiddle.net/b5275c32/. You can check how after scrolling you get the last visible column updated. There’s also a getFirstVisibleColumn if you’d need it.

3) Programmatically select/click the cell referenced in point # 2
You can use the selectCell Method. Here’s http://jsfiddle.net/2x5ofxxr/ an updated example of what I shared in point 2. If you use the mouse on scrollbar you can see that the selection moves with the next columns that appear on the right side of the table.

Hi Aleksandra,

Thank you for your prompt response.

  1. For point # 2 and point # 3 I am able to get and select the last cell in current viewport on desktop but the cell is not getting selected on ipad. Are there any different events for ipad scroll?

  2. Also, when we do vertical scroll, even then the event ‘afterScrollHorizontally’ is getting fired. Due to this I am not able to scroll the table vertically, since the first cell of last column would be selected. Can I do anything else about this?

Please let us know.

Thanks,
Polaris team.

Hi Aleksandra,

Did you get a chance to review my question asked earlier? Can you please let us know?

Thanks,
Polaris team.

Sorry for keeping you waiting @ap1

Please notice that Handsontable can work buggy on mobile devices.

With the vertical and horizontal scroll, there is one issue associated at https://github.com/handsontable/handsontable/issues/4512
I have added this issue to our list of annoying bugs and I believe it will be fixed soon. I think that we will be able to get the scrolling direction left-right or up-down via getLastVisibleColumn and getLastVisibleRow. We just need to compare the values of upcoming indexes.

Please let me know if something that I’ve written is unclear or you need further guidance.

Great! Thanks for the information.

Also, I noticed one more thing that ‘horizontal scroll event’ is not getting triggered on ipad. Is this a known issue, or we have some other events associated for scroll to be handled on mobile devices? Do we have any other way we have access ‘horizontal scroll event’ on mobile devices, especially ‘ipad’?

Thanks,
Polaris team.

Hi @ap1

what we are doing on iPad/iPhone is actually not scrolling. We just move the already rendered part of the table. Even when you have a scrollbar on the website in the mobile version it is gone.

Chrome, Windows 10

iPhone

If you would like to do anything when a user moves the table you would need to use browser native touch events.