diff --git a/demo/css/myTheme.css b/demo/css/myTheme.css index 25a596d..83cd7fe 100644 --- a/demo/css/myTheme.css +++ b/demo/css/myTheme.css @@ -104,6 +104,8 @@ } .fancyTable thead tr th, +.fancyTable thead tr td, +.fancyTable tfoot tr th, .fancyTable tfoot tr td { /* appearance */ background-color: #8ca9cf; diff --git a/demo/demo.js b/demo/demo.js index 2ed6bf0..45f27a0 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -5,7 +5,9 @@ $(document).ready(function() { $('.myTable02').fixedHeaderTable({ height: '250', footer: true, altClass: 'odd', themeClass: 'fancyTable' }); - $('.myTable03').fixedHeaderTable({ height: '400', altClass: 'odd', footer: true, fixedColumn: true, themeClass: 'fancyTable' }); + $('.myTable03').fixedHeaderTable({ height: '400', altClass: 'odd', footer: true, fixedColumns: 1, themeClass: 'fancyTable' }); $('.myTable04').fixedHeaderTable({ height: '400', altClass: 'odd', footer: true, cloneHeadToFoot: true, fixedColumns: 3, themeClass: 'fancyTable' }); + + $('.myTable05').fixedHeaderTable({ height: '400', altClass: 'odd', footer: true, fixedColumns: 1, themeClass: 'fancyTable' }); }); \ No newline at end of file diff --git a/demo/test.html b/demo/test.html index 45b2fb6..27ee8bc 100644 --- a/demo/test.html +++ b/demo/test.html @@ -375,6 +375,319 @@ $('.myTable02').fixedHeaderTable({
+
+
+$('.myTable05').fixedHeaderTable({
+ height: '400',
+ altClass: 'odd',
+ footer: true,
+ fixedColumns: 1,
+ themeClass: 'fancyTable'
+});
+
+
+ Browser | +Visits | +Pages/Visit | +Avg. Time on Site | +% New Visits | +Bounce Rate | +Avg. Time on Site | +% New Visits | +Bounce Rate | +
---|---|---|---|---|---|---|---|---|
Browser | +Visits | +Pages/Visit | +Avg. Time on Site | +% New Visits | +Bounce Rate | +Avg. Time on Site | +% New Visits | +Bounce Rate | +
Firefox first | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 test test test | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% test test test | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
Firefox | +1,990 | +3.11 | +00:04:22 | +70.00% | +32.61% | +00:04:22 | +70.00% | +32.61% | +
@@ -383,7 +696,7 @@ $('.myTable03').fixedHeaderTable({ height: '400', altClass: 'odd', footer: true, - fixedColumn: true, + fixedColumns: 1, themeClass: 'fancyTable' }); diff --git a/jquery.fixedheadertable.js b/jquery.fixedheadertable.js index 4640508..a626ed3 100644 --- a/jquery.fixedheadertable.js +++ b/jquery.fixedheadertable.js @@ -342,7 +342,7 @@ 'margin-left': -this.scrollLeft }); - if (settings.cloneHeadToFoot) { + if (settings.footer || settings.cloneHeadToFoot) { $tfoot.find('table') .css({ 'margin-left': -this.scrollLeft @@ -397,15 +397,15 @@ $fixedColumn = $wrapper.find('.fht-fixed-column'), $thead = $(''), $tbody = $('
'), - $tfoot = $(''), - $firstThChildren,// = $fixedBody.find('.fht-thead thead tr th:first-child'), + $tfoot = $('
'), + $firstThChildren,// = $fixedBody.find('.fht-thead thead tr > *:first-child'), $firstTdChildren, fixedColumnWidth,// = $firstThChild.outerWidth(true) + tableProps.border, fixedBodyWidth = $wrapper.width(), fixedBodyHeight = $fixedBody.find('.fht-tbody').height() - settings.scrollbarOffset, $newRow; - $firstThChildren = $fixedBody.find('.fht-thead thead tr th:lt(' + settings.fixedColumns + ')'); + $firstThChildren = $fixedBody.find('.fht-thead thead tr > *:lt(' + settings.fixedColumns + ')'); fixedColumnWidth = settings.fixedColumns * tableProps.border; $firstThChildren.each(function(index) { fixedColumnWidth += $(this).outerWidth(true); @@ -420,7 +420,7 @@ tdWidths.push($(this).width()); }); - firstTdChildrenSelector = 'tbody tr td:not(:nth-child(n+' + (settings.fixedColumns + 1) + '))'; + firstTdChildrenSelector = 'tbody tr > *:not(:nth-child(n+' + (settings.fixedColumns + 1) + '))'; $firstTdChildren = $fixedBody.find(firstTdChildrenSelector) .each(function(index) { helpers._fixHeightWithCss($(this), tableProps); @@ -479,14 +479,17 @@ // setup clone footer with fixed column if (settings.footer == true || settings.cloneHeadToFoot == true) { - var $firstTdFootChild = $fixedBody.find('.fht-tfoot thead tr th:lt(' + settings.fixedColumns + ')'); + var $firstTdFootChild = $fixedBody.find('.fht-tfoot tr > *:lt(' + settings.fixedColumns + ')'); helpers._fixHeightWithCss($firstTdFootChild, tableProps); $tfoot.appendTo($fixedColumn) .find('tr') .append($firstTdFootChild.clone()); + // Set (view width) of $tfoot div to width of table (this accounts for footers with a colspan) + footwidth = $tfoot.find('table').innerWidth(); $tfoot.css({ - 'top': settings.scrollbarOffset + 'top': settings.scrollbarOffset, + 'width': footwidth, }); } }, @@ -556,15 +559,15 @@ tableProp.border = ($obj.find('th:first-child').outerWidth() - $obj.find('th:first-child').innerWidth()) / borderCollapse; - $obj.find('thead tr:first-child th').each(function(index) { + $obj.find('thead tr:first-child > *').each(function(index) { tableProp.thead[index] = $(this).width() + tableProp.border; }); - $obj.find('tfoot tr:first-child td').each(function(index) { + $obj.find('tfoot tr:first-child > *').each(function(index) { tableProp.tfoot[index] = $(this).width() + tableProp.border; }); - $obj.find('tbody tr:first-child td').each(function(index) { + $obj.find('tbody tr:first-child > *').each(function(index) { tableProp.tbody[index] = $(this).width() + tableProp.border; }); @@ -578,10 +581,10 @@ _setupClone: function($obj, cellArray) { var $self = $obj, selector = ($self.find('thead').length) ? - 'thead th' : + 'thead tr:first-child > *' : ($self.find('tfoot').length) ? - 'tfoot td' : - 'tbody td', + 'tfoot tr:first-child > *' : + 'tbody tr:first-child > *', $cell; $self.find(selector).each(function(index) {