always add colgroup & col, for consistency

This commit is contained in:
Mottie 2013-01-18 14:53:33 -06:00
parent a4cad415d2
commit d680b630b1

View File

@ -443,14 +443,25 @@
} }
} }
// automatically add col group, and column sizes if set
function fixColumnWidth(table) { function fixColumnWidth(table) {
if (table.config.widthFixed && $(table).find('colgroup').length === 0) { var $c, c = table.config,
var colgroup = $('<colgroup>'), $cg = $('<colgroup>'),
overallWidth = $(table).width(); $cgo = c.$table.find('colgroup'),
$("tr:first td", table.tBodies[0]).each(function() { n = c.parsers.length,
colgroup.append($('<col>').css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%')); overallWidth = c.$table.width();
$("tr:first td", table.tBodies[0]).each(function(i) {
$c = $('<col>');
if (c.widthFixed) {
$c.css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%');
}
$cg.append($c);
}); });
$(table).prepend(colgroup); // replace colgroup contents
if ($cgo.length) {
$cgo.html( $cg.html() );
} else {
c.$table.prepend( $cg );
} }
} }