How to add background color + border dynamically to keep together

Tags: #<Tag:0x00007f8b184470a0>

Dear developers,

how can I add background color + border dynamically to keep together please? I prepared demo available at
https://jsfiddle.net/janzitniak/h6oac8pb/7/
please select any cell then click to to button Add background color and to the same cell use Add border button. It keeps only last formatting but I would like to keep both of them (background color and bordering as well).

Regards,
Jan

Hi @jan.zitniak

I think the better option is used classList - https://developer.mozilla.org/en-US/docs/Web/API/Element/classList

Then we don’t have a problem with an add another class to element (cell).

Here is an updated demo - https://jsfiddle.net/qtvduL21/

Hi @piotr.nowak,

thank you for your prompt answer, now it works as I expected. I would like to thank you for your professional approach.

EDIT: After several days I tried classList but the problem is if I work with any cell (its editing, autofill) the formatting will disappeared. If I use setCellMeta in my https://jsfiddle.net/janzitniak/h6oac8pb/7/ then formatting stays but how can I background color + border dynamically to keep together as I described in my main question?

Regards,
Jan