Last active
April 24, 2020 11:02
-
-
Save reachkamrul/52902cbeeffb342de98f1da9ce51b567 to your computer and use it in GitHub Desktop.
Auto Colspan for same cell data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function() { | |
function ninjaTableAutoColspan() | |
{ | |
if($table.hasClass('ninja_stacked_table')) { | |
return; | |
} | |
$table.find('tr').each(function() { | |
var tr = this; | |
var counter = 0; | |
var strLookupText = ''; | |
var isHTML = RegExp.prototype.test.bind(/(<([^>]+)>)/i); | |
jQuery('td', tr).each(function(index, value) { | |
var td = jQuery(this); | |
if(!isHTML(td[0].innerHTML) && td[0].innerHTML !== ''){ | |
if ((td.text() === strLookupText) ) { | |
counter++; | |
td.prev().attr('colspan', '' + parseInt(counter + 1,10) + '').css({textAlign : 'center'}); | |
td.remove(); | |
} | |
} | |
else { | |
counter = 0; | |
} | |
strLookupText = td.text(); | |
}); | |
}); | |
} | |
ninjaTableAutoColspan(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment