Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html table span if the data is same

I have a html table with duplicate data in the column as shown below

enter image description here

I want to dynamically merge the html table row cell if the data is same like below table

enter image description here

I am able to do this with giving the value number of cells to span but how can I do this dynamically

like image 744
PSSR Avatar asked Nov 20 '13 10:11

PSSR


1 Answers

Wow, thanks for the interesting task. I came up with this solution http://jsfiddle.net/PhWGF/4/. Not the cleanest code but I will leave this part for you.

You can think about your table as a regular 2d array so it all comes down to the classical nested loops. We search for a duplicate for each cell in each row of the same column, store first and last occurrence to determine the length of span later.

Note, you need to set all "roswpan" before deleting duplicates.

like image 158
mdolbin Avatar answered Nov 11 '22 16:11

mdolbin