我正在使用tablesorter v.2.28.7的fork,我正在尝试添加一个select过滤器。在使用选择过滤器之前,一切都按预期工作,因此使用普通文本过滤......
这是我提前的表
<table id="stopsTable">
<thead>
<tr>
<th><spring:message code="id" /></th>
<th><spring:message code="stop.user" /></th>
<th data-placeholder="---"><spring:message code="stop.park" /></th>
<th><spring:message code="stop.from" /></th>
<th><spring:message code="stop.to" /></th>
<th><spring:message code="stop.price" /></th>
<th><spring:message code="stop.status" /></th>
<th class="filter-false"><span class="pull-right"><spring:message
code="actions" /></span></th>
</tr>
</thead>
然后是js
$(document).ready(function() {
$("#stopsTable")
.tablesorter({
headers: {
7: {sorter: false},
3: {sorter: 'customDate'},
4: {sorter: 'customDate'}
},
theme: "bootstrap",
widthFixed: true,
headerTemplate : '{content} {icon}', // new in v2.7. Needed to add the bootstrap icon!
widgets : [ "uitheme", "filter", "columns", "zebra", "pager" ],
widgetOptions : {
zebra : ["even", "odd"],
columns: [ "primary", "secondary", "tertiary" ],
filter_reset : ".reset",
filter_cssFilter: "form-control",
pager_output: '{startRow:input} {endRow} / {totalRows} row',
pager_updateArrows: true,
pager_startPage: 0,
pager_size: 10,
pager_removeRows: false,
filter_ignoreCase : true,
filter_searchDelay : 300,
filter_functions : {
2 : true,
},
},
})
});
$.tablesorter.addParser({
id: "customDate",
is: function(s) {
//return false;
//use the above line if you don't want table sorter to auto detected this parser
//21/04/2010 03:54 is the used date/time format
return /\d{1,2}\/\d{1,2}\/\d{1,4} \d{1,2}:\d{1,2}/.test(s);
},
format: function(s) {
s = s.replace(/\-/g," ");
s = s.replace(/:/g," ");
s = s.replace(/\./g," ");
s = s.replace(/\//g," ");
s = s.split(" ");
return $.tablesorter.formatFloat(new Date(s[2], s[1]-1, s[0], s[3], s[4]).getTime());
},
type: "numeric"} );
我还尝试将“filter-select”类添加到但是我得到了这个异常
Uncaught TypeError: Cannot read property 'text' of undefined
此时:
jquery.tablesorter.widgets.js:2003
答案 0 :(得分:0)
在共享的演示中,HTML无效...... isok = False
try:
#try to do something
isok = True
except err1:
#do something besides raising an exception
except err5:
#do something besides raising an exception
if not isok:
raise SystemExit
和</thead>
之间是额外的<tbody>
<tr>
这导致javascript错误。如果您删除了</thead>
<tr>
<tbody>
,则演示无任何问题 - https://jsfiddle.net/bbxxomhx/401/