mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
always add colgroup & col, for consistency
This commit is contained in:
parent
a4cad415d2
commit
d680b630b1
@ -443,14 +443,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
// automatically add col group, and column sizes if set
|
||||
function fixColumnWidth(table) {
|
||||
if (table.config.widthFixed && $(table).find('colgroup').length === 0) {
|
||||
var colgroup = $('<colgroup>'),
|
||||
overallWidth = $(table).width();
|
||||
$("tr:first td", table.tBodies[0]).each(function() {
|
||||
colgroup.append($('<col>').css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%'));
|
||||
});
|
||||
$(table).prepend(colgroup);
|
||||
var $c, c = table.config,
|
||||
$cg = $('<colgroup>'),
|
||||
$cgo = c.$table.find('colgroup'),
|
||||
n = c.parsers.length,
|
||||
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);
|
||||
});
|
||||
// replace colgroup contents
|
||||
if ($cgo.length) {
|
||||
$cgo.html( $cg.html() );
|
||||
} else {
|
||||
c.$table.prepend( $cg );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user