I have the following scripts to freeze my table. This works fine in Landscape/Portrait mode of screen but when table is loaded in landscape mode and rotated to portrait, the old clone(fixed header {fix_thead})
resides with same width. On orientation change
jQuery(window).bind('orientationchange', function (e) {CheckInvTableFreeze ();}
I am calling the freeze header function again to adjust the freeze header width with new table header. On changing the orientation again multiple freezed header is appearing. How to have only one fixed table head based on my original table.
var CheckInvTableFreeze = function myfunction() {
var CiTable = $('#myTable'),
CiThead = CiTable.find('thead'),
fix_thead;
CiThead.find('th').each(function () {
var el = $(this);
el.css('width', el.width());
});
fix_thead = CiThead.clone().hide();
CiThead.after(fix_thead);
fix_thead.css(
{
'position': 'fixed',
'top': 0,
'width': CiThead.width()
});
$(document).on('scrollstart', function (e) {
if ($(this).scrollTop() > $('#myTable').offset().top) {
fix_thead.show();
}
else {
fix_thead.hide();
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…