Error when cells are out of the screen

Tags: #<Tag:0x00007f8b1db5ad38> #<Tag:0x00007f8b1db5ab08>

I am setting some cells with background color and my code works fine just with the cells on screen, otherwise does not.

And when I click in the horizontal scrollbar background disappears.

Thank you.

Hi @jelm48

Here we have an example showing how to change cell background color. I added more rows force the scrollbar and it works fine:

https://jsfiddle.net/aszymanski/hpvw1rgk/

Hello @adrian.szymanski

Please, open this link and see my problem.

https://www.awesomescreenshot.com/video/14513905?key=6484f48d76f3107ff7347e9ccd1544f9

And my code works fine when cells are in screen (purple color, 30 cells).
descarga

But my code does not work fine when cells are out of screen(green color). I mean, I am trying to add background color for 30 cells but just 8 cells were setting.

Thank you.

Hi @jelm48

Can you please modify my example to show us the issue? Without knowing the code it will be hard to debug.

Hi @adrian.szymanski

I think my problem is due to use getCell. According to Handsontable documentation, this method “Returns a TD element for the given row and column arguments, if it is rendered on screen. Returns null if the TD is not rendered on screen (probably because that part of the table is not visible).”

How can I get TD element for those cells are out of the screen? I mean, how can I get TD element when part of the table is not visible?

Thank you.

Hi @jelm48

Can you share your code? I’d like to see your implementation. However, we recommend to set the custom cell background in a way that I showed in my example, by using cells option.

Sure @adrian.szymanski

But First at all I need to know if some cell has already backgroundcolor. If so, I check the next cell until no background color. After that, I use cells to set background Color just like you told me.

This piece of code works fine when the table is visible and I need to check some cells not visible.
if (hot.current.hotInstance.getCell(i, coords.col).style.backgroundColor === “”)

Thank you again.

Hi @adrian.szymanski

I already solved my issue. Here is the solution: viewportRowRenderingOffset={70}
viewportColumnRenderingOffset={250}

Thank you for your support.

I think this topic can be closed.

Kind regards

Hi @jelm48

I’m glad you made it work.