Merging cells disappear

Tags: #<Tag:0x00007f8b23e8d338>

Dear developers,

I would like to merge cells in dynamically way by user clicking on button. My demo works if the user clicks once but if clicks more times the previous merging disappears.

Demo avalaible here
https://jsfiddle.net/janzitniak/84rvjtun/4/

Regards
Jan

Hi Jan.

Here

hot.updateSettings({
   mergeCells: [
      { row: startRow, col: startCol, rowspan: (endRow - startRow) + 1, colspan: (endCol - startCol) + 1}
   ]
})

you’d need to push another object. As currently whatever is already set you still define one object (one merged area) for mergeCells array.

Dear @aleksandra_budnik,

thank you for your quick response. I’m working on workaround and I would like ask you - is it possible updateSettings by passing parameters in the string?

I mean somenthing like this:

  var whichMergedCells = '[{row:1,col:0,rowspan:3,colspan:1},{row:0,col:3,rowspan:2,colspan:2}]';
  hot.updateSettings({
    mergeCells: whichMergedCells
  })

Demo available at
https://jsfiddle.net/janzitniak/84rvjtun/18/
Note: Please click to Merge button

Regards
Jan

Hi Jan.

You can use JSON.parse() method https://jsfiddle.net/AMBudnik/byd743ow/

So simple! Thank you again Aleksandra :blush:

1 Like