开发者

Jquery Datatable sorting error with date

We have an issue where we have a table with 7 columns and if we sort on multiple columns in IE 7 where the first sort column is a string and the second sort column is a Date, the paging stops working. In FireFox we get the error: 'q[d + ("-" + k[f][1])]' is not a function. Here is the code:

$(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开发者_如何学C));
        };

        $('.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]


        });

    });


Have you tried setting the first object in aoColumns to only the property name like this?

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


You should use 'date' unless you have the Date (dd/mm/yy) plugin installed.

'aoColumns': [{ "sType": 'date' }, null, null, null, null, null, null]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜