From f6185db9ac9dfb3c203b3ba49a72e442c2fb9553 Mon Sep 17 00:00:00 2001 From: Mottie Date: Thu, 14 Feb 2013 11:37:01 -0600 Subject: [PATCH] revert code that always adds a colgroup - fixes issue #238 --- js/jquery.tablesorter.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/js/jquery.tablesorter.js b/js/jquery.tablesorter.js index 4de2dd46..d339d303 100644 --- a/js/jquery.tablesorter.js +++ b/js/jquery.tablesorter.js @@ -449,23 +449,13 @@ // automatically add col group, and column sizes if set function fixColumnWidth(table) { - var $c, c = table.config, - $cg = $(''), - $cgo = c.$table.find('colgroup'), - n = c.columns.length, - overallWidth = c.$table.width(); - $("tr:first td", table.tBodies[0]).each(function(i) { - $c = $(''); - 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 ); + if (table.config.widthFixed && $(table).find('colgroup').length === 0) { + var colgroup = $(''), + overallWidth = $(table).width(); + $("tr:first td", table.tBodies[0]).each(function() { + colgroup.append($('').css('width', parseInt(($(this).width()/overallWidth)*1000, 10)/10 + '%')); + }); + $(table).prepend(colgroup); } }