Skip to main content
Inspiring
August 13, 2020
Answered

Javascript | How to know if a cell is merged in a table?

  • August 13, 2020
  • 5 replies
  • 1481 views

Hi,

 

I'm currently working on a script that applies a background color to a column.

With simple table it works fine, but when on the first rown there is two cells merged, and if I select the merged cells and the two columns below, it only colors the first one.

 

I thought that if I knew if the selected cell is a merged cell, I could easily color the selected column.

 

Many thanks,

Nicolas

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Jongware

columnSpan is for horizontal merges, rowSpan for vertical, so best check both (http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pc_Cell.html)

5 replies

Peter Kahrel
Community Expert
Community Expert
August 13, 2020

If a cell's rowSpan is greater than 1 it's horizontally merged.

if (myCell.rowSpan > 1)

P.

Jongware
Community Expert
JongwareCommunity ExpertCorrect answer
Community Expert
August 13, 2020

columnSpan is for horizontal merges, rowSpan for vertical, so best check both (http://jongware.mit.edu/idcs5.5js_html/idcs5.5js/pc_Cell.html)

Nicolas_HAuthor
Inspiring
August 13, 2020

Wow, thanks to both of you, that's exactly what I needed!

Have a nice day 🙂

 

Nicolas