Highlighted

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

Explorer ,
Aug 13, 2020

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

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

TOPICS
Scripting

Views

46

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Explorer ,
Aug 13, 2020

Copy link to clipboard

Copied

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

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

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

TOPICS
Scripting

Views

47

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 13, 2020 0
Adobe Community Professional ,
Aug 13, 2020

Copy link to clipboard

Copied

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

if (myCell.rowSpan > 1)

P.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 13, 2020 0
Most Valuable Participant ,
Aug 13, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 13, 2020 0
Explorer ,
Aug 13, 2020

Copy link to clipboard

Copied

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

Have a nice day 🙂

 

Nicolas

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 13, 2020 0