Jquery Datatable排序错误与日期

时间:2011-01-31 22:32:52

标签: jquery sorting date datatable

我们遇到一个问题,我们有一个包含7列的表,如果我们在IE 7中对多列进行排序,其中第一个排序列是字符串,第二个排序列是日期,则分页停止工作。在FireFox中我们得到错误:'q [d +(“ - ”+ k [f] [1])]'不是函数。这是代码:

$(document).ready(function () {

        jQuery.fn.dataTableExt.oSort['us_date-asc'] = function (a, b) {
            var x = new Date(a),
             y = new Date(b);
            return ((x < y) ? -1 : ((x > y) ? 1 : 0));
        };

        jQuery.fn.dataTableExt.oSort['us_date-desc'] = function (a, b) {
            var x = new Date(a),
             y = new Date(b);
            return ((x < y) ? 1 : ((x > y) ? -1 : 0));
        };

        $('.tbl').dataTable({
            'bFilter': false,
            'bSort': true,
            'bLengthChange': false,
            'sPaginationType': 'two_button',
            'bRetrieve': true,
            'iDisplayLength': 25,
            'aaSorting': [[6, 'asc'], [0, 'asc']],
            'aoColumns': [{ "sType": 'us_date-asc' }, null, null, null, null, null, null]
            //We also tried using this:   'aoColumns': [{ "sType": "date" }, null, null, null, null, null, null]


        });

    });

2 个答案:

答案 0 :(得分:1)

您是否尝试过将aoColumns中的第一个对象设置为只有这样的属性名称?

'aoColumns': [{ "sType": 'us_date' }, null, null, null, null, null, null]

答案 1 :(得分:1)

除非您安装了日期(年/月/日)插件,否则应使用'date'

'aoColumns': [{ "sType": 'date' }, null, null, null, null, null, null]
相关问题