Jquery 表排序器&x2B;日期选择器日期格式已损坏

Jquery 表排序器&x2B;日期选择器日期格式已损坏,jquery,datepicker,jquery-ui-datepicker,tablesorter,Jquery,Datepicker,Jquery Ui Datepicker,Tablesorter,在tablesorterk中使用datepicker时,如它所说: //在此处添加任何jQuery UI日期选择器选项(http://api.jqueryui.com/datepicker/) 我们可以假设它包括dateFormat,但出于某种原因,唯一有效的dateFormat是示例中的一种和默认值 有效 dateFormat : 'M dd, yy' // comparison: Oct 13, 2013 dateFormat : 'M dd, yy' // comparison Sep

在tablesorterk中使用datepicker时,如它所说:

//在此处添加任何jQuery UI日期选择器选项(http://api.jqueryui.com/datepicker/)

我们可以假设它包括
dateFormat
,但出于某种原因,唯一有效的dateFormat是示例中的一种和默认值

有效

dateFormat : 'M dd, yy'
// comparison: Oct 13, 2013

dateFormat : 'M dd, yy'
// comparison Sep 22, 2013
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/cupertino/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="jquery.tablesorter.min.js"></script>
<script src="jquery.metadata.js"></script>
<script src="jquery.tablesorter.widgets.js"></script>
<script src="jquery.tablesorter.widgets-filter-formatter.js"></script>
不起作用

dateFormat : 'D M dd'
// comparison: Fri Oct 04

dateFormat : 'M dd'
// comparison Sep 22
例如:

JQuery

$(function() {
  $("table").tablesorter({
    widthFixed : true,

    widgets: ["filter"],
    widgetOptions : {
      filter_formatter : {
        0 : function($cell, indx){
          return $.tablesorter.filterFormatter.uiDateCompare( $cell, indx, {
            dateFormat : 'D, M dd, yy',
            changeMonth : true,
            changeYear : true,
            compare : '='
          });
        }
      }
    }
  });
});
HTML

<table class="tablesorter">
  <thead>
    <tr>
      <th data-placeholder="Sort By Date">Date (one input; greater than)</th>
    </tr>
  </thead>
  <tbody>
    <tr><td>Wed, Jun 26, 2013</td></tr>
    <tr><td>Wed, Aug 21, 2013</td></tr>
    <tr><td>Sun, Oct 13, 2013</td></tr>
    <tr><td>Sat, Jul 6, 2013</td></tr>
    <tr><td>Tue, Dec 10, 2012</td></tr>
  </tbody>
</table>

日期(一次输入;大于)
2013年6月26日,星期三
2013年8月21日,星期三
2013年10月13日,星期日
2013年7月6日,星期六
2012年12月10日,星期二
这是对日期格式的一个小更改,但会导致表无法进行筛选。是否需要不同的格式?我错过图书馆了吗

dateFormat : 'M dd, yy'
// comparison: Oct 13, 2013

dateFormat : 'M dd, yy'
// comparison Sep 22, 2013
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/cupertino/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>
<script src="jquery.tablesorter.min.js"></script>
<script src="jquery.metadata.js"></script>
<script src="jquery.tablesorter.widgets.js"></script>
<script src="jquery.tablesorter.widgets-filter-formatter.js"></script>

此问题可能是因为插件未将该列检测为日期列。分拣机最终使用重新格式化的日期列的默认文本解析器,因此排序可能会出错

当筛选器比较日期时,它会查找该列的已解析数据,并将其与输入的筛选器(也已解析)进行比较

我没有做一个完整的语法分析器,但是试着包含这个语法分析器,看看它是否适合您

$.tablesorter.addParser({
    id: "date-ignore-weekday",
    is: function (s) {
        return false;
    },
    format: function (s, table) {
        // probably not the best regex, but it works
        var date = s.match(/\w+,\s+(.*)/);
        return date ? new Date(date[1] || '').getTime() : s;
    },
    type: "numeric"
});

$('table').tablesorter({
    theme: 'blackice',
    headers: {
        0: {
            sorter: "date-ignore-weekday"
        }
    }
});

此问题可能是由于插件未将该列检测为日期列。分拣机最终使用重新格式化的日期列的默认文本解析器,因此排序可能会出错

当筛选器比较日期时,它会查找该列的已解析数据,并将其与输入的筛选器(也已解析)进行比较

我没有做一个完整的语法分析器,但是试着包含这个语法分析器,看看它是否适合您

$.tablesorter.addParser({
    id: "date-ignore-weekday",
    is: function (s) {
        return false;
    },
    format: function (s, table) {
        // probably not the best regex, but it works
        var date = s.match(/\w+,\s+(.*)/);
        return date ? new Date(date[1] || '').getTime() : s;
    },
    type: "numeric"
});

$('table').tablesorter({
    theme: 'blackice',
    headers: {
        0: {
            sorter: "date-ignore-weekday"
        }
    }
});

我遇到了同样的问题,我找到了这个解决方案

我的日期格式为ddmmyyyy,例如2014年1月24日(1月)

这适用于jquery.tablesorter.widgets-filter-formatter.js

过滤器小部件格式化程序功能-2013年11月9日更新(v2.13.3)

第363行:添加此行
dateFormat:'dd/mm/yy'//设置默认日期格式

所以代码现在是

等。无需更改此文件中的任何其他内容

您可以在其中设置表格分拣机参数

dateFormat:“ddmmyyyy”//设置默认日期格式

等等


享受。

我遇到了同样的问题,我找到了这个解决方案

我的日期格式为ddmmyyyy,例如2014年1月24日(1月)

这适用于jquery.tablesorter.widgets-filter-formatter.js

过滤器小部件格式化程序功能-2013年11月9日更新(v2.13.3)

第363行:添加此行
dateFormat:'dd/mm/yy'//设置默认日期格式

所以代码现在是

等。无需更改此文件中的任何其他内容

您可以在其中设置表格分拣机参数

dateFormat:“ddmmyyyy”//设置默认日期格式

等等

享受