Из-за моих зависимостей от других плагинов: jScrollPane, Tablesorter и т. Д. Было трудно найти идеальное решение для плагина для моей проблемы.
Итак, я сам написал код:)
Это не завершено, но суть в следующем:
$(function() {
var $headLength = $("#quotations thead th").length;
$("#quotations thead th").each(function(index) {
$thisWidth = $(this).attr("width");
//console.log($thisWidth);
$("#quotations tbody tr:first td:eq(" + index + ")").attr("width", $thisWidth)
});
var $clonedHead = $("#quotations thead")
.clone()
.insertBefore(".w_price_assess .jScrollPaneContainer")
.wrap('<table id="quotations_clone" />');
$("#quotations thead").hide();
$(".w_price_assess").delegate("#quotations_clone thead th", "click", function() {
var $this = $(this);
var $thIndex = $this.index("#quotations_clone thead th");
$("#quotations thead th:eq(" + $thIndex + ")").trigger("click");
});
$(".w_price_assess table.pricing").tablesorter({
// change the multi sort key from the default shift to alt button
sortMultiSortKey: 'shiftKey'
});
// re-apply zebra striping after sort
$(".w_price_assess table.pricing").bind("sortEnd", function() {
$("table.striped .odd").removeClass("odd");
$("table.striped tbody tr:nth-child(odd)").addClass("odd");
});
});
Таким образом, я клонирую thead таблицы, которую я хочу, и затем вставляю ее поверх фактической таблицы.
Tablesorter по-прежнему активен, проверяя, по какому элементу нового нового клика щелкнули, а затем с помощью невероятного метода триггера jQuery, чтобы вызвать щелчок по соответствующему th в скрытой заголовке таблицы.