[GH #6359] Formula is converted to a value if merged areas are included

Tags: #<Tag:0x00007f34422f0260> #<Tag:0x00007f34422fb818>

Hello,

any news to the issue when formula is converted to a value if cell are merged? I found the issue described at https://github.com/handsontable/handsontable/issues/6359
but the problem remains …

Regards
Jan

Hey Jan,

when it comes to formulas we have focused on creating a plugin for the new engine. Hopefully, while creating the plugin we will avoid getting the same errors. However, it is not ready for tests yet.

Dear @aleksandra_budnik,

thank you for you quick response. I was working on workaround for this problem and the simplest way (maybe not the best) is store data then merging and then retrieve them, example:
https://jsfiddle.net/janzitniak/twL10sv9/5/

For storing (cloning) data I used:
var data_copy = JSON.parse(JSON.stringify(data));

And restoring them (after merging cells):

setInterval(function(){
    hot.loadData(data_copy);
}, 200)

Notice: We can’t use hot.loadData immediately (without setInterval) because we don’t know how much takes merging data.
Better way should be loadData in a callback or in afterChange event …

EDIT: There is another issue. If I used this workaround which I described above then after applying any style (e.g. changing background color of cell) the table flashes and goes back without any formatting. Steps: Click to button Set merged cells and then to Set background color cells.
https://jsfiddle.net/janzitniak/twL10sv9/8/

Good old JSON… definitely a solid workaround. Nevertheless, I hope I will be able to update you soon with the following issue being fixed.

1 Like

Thanks Alexandra, but my solution has some another problem I updated my answer above …

And now https://jsfiddle.net/handsoncode/nzq9bfyw/?
I guess that you wanted to use setTimeout, not setInterval so I’ve changed that. Then I just added ‘test’ instead of an empty string to test the class addition (line 53).

1 Like

You are right Aleksandra, I’m not so concentrated :slight_smile:.
I tried your example but if I made the following steps (clicking to the buttons):

Set merged cells - OK
Set background color cells - OK
then I
Set merged cells - it’s NOT OK because of cell color dissapears …

probably mergeCells turn off cellMeta?

The className of cell is removed as btnMergeCells button calls the loadData. The data loading method removes cell meta.

Thanks Aleksandra for the explanation. Did you find any way how to keep cell meta after loading loadData?

There is no way to do that quick and easily (a method to reload everything). But we may think about some possible approaches. To do that we need to define

  • how many classNames can be added generally (only one or more?)
  • if the above questions is ‘more than one’. Can we have two classNames for a single cell
  • can each cell has a className or only some of them (example: only those in the first column)?
  • do you want to remove any of them or once they are applied they stay attached to the cell
  • do you attach classNames by a button click to a selected cell (or cells range) or it also can be added in a different way

My answers:

  1. More
  2. Yes, we can, also more than two
  3. Each cell can has a className
  4. I want to remove any of them
  5. Yes, I attach classNames by a button click to a selected cell and range

So we do not have many patterns and basically, everything is possible.

It may mean that the only way to get this done is to create a cellmeta map that can be loaded when data is merged. I would construct the map to hold an objects of {row: index, column: index, className: string}. Cause this pattern is used by the cell method https://handsontable.com/docs/8.2.0/Options.html#cell and you do not need to call the setCellMeta dozen times.

I the future we are planning to add an ability to render ceratin cells, so you will only need to focus on re-rendering those cells that had a class before they were merged. However, this project hasn’t been put in a milestone yet. I’m mentioning it to give you some view on how this situation can evaluate in the future.

Thank for tip Aleksandra. Something what you mentioned I already did.
The best way how to resolve that problem should be fixing the bug with merging cells and everything will be ok :slight_smile:

That’s true, Jan :slight_smile:
I hope I’ll be able to share the good news sooner than later.

1 Like