Created
April 8, 2013 05:33
-
-
Save jjacobson93/5334434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function () { | |
if (!this.$sizingHeader) return; | |
this.$element.prepend(this.$sizingHeader); | |
var $sizingCells = this.$sizingHeader.find('th'); | |
var columnCount = $sizingCells.length; | |
var tableWidth = $sizingCells.parent().width(); // Used to calculate the width percent | |
function matchSizingCellWidth(i, el) { | |
// if (i === columnCount - 1) return; // Shouldn't every cell change width when resized? | |
var width = $sizingCells.eq(i).width(); | |
$(el).width((width/tableWidth)*100 + "%"); // Using percentage of table width | |
} | |
this.$colheader.find('th').each(matchSizingCellWidth); | |
// Add the header row to the tbody | |
var headerRow = this.$colheader.clone(); | |
headerRow.find('i').remove(); //Remove the sort icon | |
this.$tbody.prepend(headerRow); | |
// Hide the header row | |
headerRow.find('th').each(function(i,e) { | |
$(e).css({'height':'0px', | |
'line-height':'0px', | |
'overflow':'hidden', | |
'padding':'0px', | |
'border':'none'}); | |
}); | |
this.$tbody.find('tr:first > td').each(matchSizingCellWidth); | |
// Fix border issue | |
this.$tbody.find('tr:not(tr:first):first td').each(function(i, el) { | |
$(el).css('border-top', 'none'); | |
}); | |
this.$sizingHeader.detach(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment