Looking to table a raw table and find all identical adjacent row cells and create a row span for it using Javescript.
found this code in this SO. How to modify attribute ROWSPAN with jQuery?
function modifyTableRowspan(column) {
var prevText = "";
var counter = 0;
column.each(function (index) {
var textValue = $(this).text();
if (index === 0) {
prevText = textValue;
}
if (textValue !== prevText || index === column.length - 1) {
var first = index - counter;
if (index === column.length - 1) {
counter = counter + 1;
}
column.eq(first).attr('rowspan', counter);
if (index === column.length - 1)
{
for (var j = index; j > first; j--) {
column.eq(j).remove();
}
} else {
for (var i = index - 1; i > first; i--) {
column.eq(i).remove();
}
}
prevText = textValue;
counter = 0;
}
counter++;
});
}
At first seemed to do the trick very nicely. But, during testing I discovered that the last row doesn't seem to work right. See this https://jsfiddle.net/eupb0fmx/3/
Haven't been able to figure out what is going on. thanks in advance. Dave