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) {
|
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) {
|
||||||
$(table).prepend(colgroup);
|
$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