Cell Hook inside afterOnCellMouseDown hook

Tags: #<Tag:0x00007fee36d38b88>

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:


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:


This is my demo:

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.