$(function() {
// NOTE: $.tablesorter.theme.bootstrap is ALREADY INCLUDED in the jquery.tablesorter.widgets.js
// file; it is included here to show how you can modify the default classes
$.tablesorter.themes.bootstrap = {
// these classes are added to the table. To see other table classes available,
// look here: http://getbootstrap.com/css/#tables
table : 'table table-bordered table-striped',
caption : 'caption',
// header class names
header : 'bootstrap-header', // give the header a gradient background (theme.bootstrap_2.css)
sortNone : '',
sortAsc : '',
sortDesc : '',
active : '', // applied when column is sorted
hover : '', // custom css required - a defined bootstrap style may not override other classes
// icon class names
icons : '', // add "icon-white" to make them white; this icon class is added to the <i> in the header
iconSortNone : 'bootstrap-icon-unsorted', // class name added to icon when column is not sorted
iconSortAsc : 'glyphicon glyphicon-chevron-up', // class name added to icon when column has ascending sort
iconSortDesc : 'glyphicon glyphicon-chevron-down', // class name added to icon when column has descending sort
filterRow : '', // filter row class; use widgetOptions.filter_cssFilter for the input/select element
footerRow : '',
footerCells : '',
even : '', // even row zebra striping
odd : '', // odd row zebra striping
sortMultiSortKey: 'shiftKey',
};
$('#resetsort').click(function(e) {
$("#receipts").trigger('sortReset').trigger('applyWidgets');
return false;
});
// call the tablesorter plugin and apply the uitheme widget
$("#receipts").tablesorter({
// this will apply the bootstrap theme if "uitheme" widget is included
// the widgetOptions.uitheme is no longer required to be set
theme : "blue",
widthFixed: true,
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
// widget code contained in the jquery.tablesorter.widgets.js file
// use the zebra stripe widget if you plan on hiding any rows (filter widget)
widgets : [ "uitheme", "filter", "zebra" ],
widgetOptions : {
// using the default zebra striping class name, so it actually isn't included in the theme variable above
// this is ONLY needed for bootstrap theming if you are using the filter widget, because rows are hidden
zebra : ["even", "odd"],
// reset filters button
filter_reset : ".reset",
// extra css class name (string or array) added to the filter element (input or select)
filter_cssFilter: "form-control",
// set the uitheme widget to use the bootstrap theme class names
// this is no longer required, if theme is set
// ,uitheme : "bootstrap"
}
})
.tablesorterPager({
// target the pager markup - see the HTML block below
container: $(".ts-pager"),
// target the pager page select dropdown - choose a page
cssGoto : ".pagenum",
// remove rows from the table to speed up the sort of large tables.
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
removeRows: false,
// output string - default is '{page}/{totalPages}';
// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
output: '{startRow} - {endRow} / {filteredRows} ({totalRows})'
});
});
function yeah() {
return confirm('Are you sue you want to delete?');
$("#receipts").trigger('applyWidgets');
return false;
}
嗨,
新手在这里运行Tablesorter也与过滤器和排序。一切工作正常(包括重置按钮)。作为一点背景知识,我正在使用一个DotNet Nuke站点,该站点具有一个提供数据行的模块。
每行的一部分是触发删除行的超链接。它还包括一个部分,我可以在其中插入一些JavaScript。
问题是,当我删除一行时,zebra小部件无法工作。(所有行均为白色)
按下删除超链接的另一部分是你确定会出现消息吗。
我的理解是,这里最好的方法是创建一个函数,因为需要执行两个操作。
函数是的是我的尝试。该页面还具有一个重新排序按钮,可以很好地工作。
我试着把我的函数放在resetsort按钮的下面,但是没有任何效果。
提前感谢您在运行此功能时提供的任何帮助。
发布于 2016-11-07 03:34:24
sortReset方法应该在应用后自动更新小部件,所以我不确定为什么在这种情况下没有发生。
无论如何,当"sortReset"被触发时,需要进行一些处理,所以在触发之后立即使用"applyWidgets“是行不通的,因为需要延迟。
"sortReset“触发器确实包含回调,因此请尝试以下代码:
$("#receipts").trigger('sortReset', [function(){
$('#receipts').trigger('applyWidgets');
}]);当我有空闲时间时,我会试着找出为什么这不会在内部发生。
https://stackoverflow.com/questions/40275709
复制相似问题