Cell Hook inside afterOnCellMouseDown hook

Tags: #<Tag:0x00007efc62050a68>

Is it possible to use Cell hook inside afterOnCellMouseDown hook?

I am trying to set background color to some cells when other cells are clicked and “setCellMeta” does not work.

Hi @jelm48

You can use setCellMeta inside afterOnCellMouseDown but you have to additionally re-render the table. Here’s an example:

https://jsfiddle.net/aszymanski/mkv0nzoL/5/

Hi @adrian.szymanski
setCellMeta does not work for me. I need to set background color by using “cells” hook but I do not know how to use it inside “afterOnCellMouseDown” hook.

Thank you.

Hi @jelm48

I see, so you can do this by using the updateSettings method and then, inside it use cells:

https://jsfiddle.net/aszymanski/mkv0nzoL/6/

This is my demo:
https://www.awesomescreenshot.com/video/12387060?key=9e9ea20596e64a0317b94da937137076

When I refresh my browser backgroundcolor disappears except color red.

That’s correct, because the color for those cells is setup in afterOnCellMouseDown hook, so it is not permanent.

You’re right @adrian.szymanski.
I thought the same.
Any idea how to solve this issue?

Thank you.

Hi @jelm48

In that case you would need to use React with Redux or other methods that let you keep the state on reload. Unfortunately, currently, we don’t have any examples showing such implementation, but we have general tutorial on using Handsontable with React and Redux:

Hello @adrian.szymanski.

Ok. I will try.
Thank you.

Please, close this topic.