問題是第二列(「Requested Statement ...」)被檢測爲日期列,解析器試圖將整個字符串轉換爲日期;這是無效的。
這裏是a demo with the relevant extracted out functions from tablesorter。其結果是:
// start with "Requested Statement 7/1/2014 - 9/16/2014"
"Requested Statement 2014/7/1/9/16/2014" => 0
所以你需要使用textExtraction
功能爲目標的日期(demo):
$('table').tablesorter({
textExtraction : function(node){
var txt = $(node).text();
if (/request/i.test(txt)) {
// return the 3rd block (first date in range)
txt = txt.split(' ')[2];
}
return txt;
}
});
注意字符串中的第二次約會時完全忽略。如果您想提出第二次約會事宜,請嘗試以下代碼(demo):
$('table').tablesorter({
textExtraction : function(node){
var d1, d2,
txt = $(node).text();
if (/request/i.test(txt)) {
// return the 3rd block (first date in range)
txt = txt.split(' ');
d1 = $.tablesorter.formatFloat(new Date(txt[2]).getTime());
d2 = $.tablesorter.formatFloat(new Date(txt[4]).getTime());
// add the times together - there is likely a better
// method but this works in this situation
txt = d1 + d2;
}
return txt;
}
});