Я хочу использовать плагин TableSorter:
http://tablesorter.com/docs/
с плагином thead:
http://www.asual.com/jquery/thead/
Пока это работает, но плагин thead использует исходный код до того, как TableSorter добавит функции сортировки, поэтому функция сортировки отсутствует в "летающей игре", если мы прокручиваем вниз.
Как я могу назначить модифицированный источник html с помощью tableorter для thead?
Мой код:
$(document).ready(function() {
$.tablesorter.addParser({
id: "axis",
is: function(s) {
return false;
},
format: function(s,table,cell) {
return $(cell).attr("axis");
},
type: "numeric"
});
$.tablesorter.addParser({
id: "floatval",
is: function(s) {
return false;
},
format: function(s) {
return s.replace(/\./g,"").replace(/,/g,".").replace(/[^0-9-.]/g, "");
},
type: "numeric"
});
$.tablesorter.addParser({
id: "germandate",
is: function(s) {
return false;
},
format: function(s) {
var a = s.split(".");
a[1] = a[1].replace(/^[0]+/g,"");
return new Date(a.reverse().join("/")).getTime();
},
type: "numeric"
});
$("#ax_overview").tablesorter({
headers: {
1:{sorter:"germandate"},
2:{sorter:"floatval"},
4:{sorter:"floatval"},
5:{sorter:"floatval"},
6:{sorter:"floatval"},
7:{sorter:"floatval"},
8:{sorter:"floatval"},
9:{sorter:"axis"},
10:{sorter:"floatval"}
}
});
$("#ax_overview").thead();
}
);
Демо-версия:
http://www.kredit -forum.info / auxmoney-renditerechner-живой t221447.htm
EDIT:
функция thead для фиксированных заголовков
_scroll = function() {
$(_tables).each(function() {
var w, s = 'thead tr th, thead tr td',
t = $('table', this.parent().prev()).get(0),
c = $('caption', t),
collapse = $(t).css('border-collapse') == 'collapse',
ths = $(s, t),
offset = _d.scrollTop() - $(t).offset().top + _magicNumber;
if (c.length) {
offset -= c.get(0).clientHeight;
}
$(s, this).each(function(index) {
var th = ths.eq(index).get(0);
w = $(th).css('width');
$(this).css('width', w != 'auto' ? w : th.clientWidth - _parseInt($(th).css('padding-left')) - _parseInt($(th).css('padding-right')) + 'px');
});
$(this).css({
display: (offset > _magicNumber && offset < t.clientHeight - $('tr:last', t).height() - _magicNumber*2) ? $(t).css('display') : 'none',
left: $(t).offset().left - _d.scrollLeft() + 'px',
width: $(t).get(0).offsetWidth
});
});
};