1

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));
        };

        $('.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
  • Could you post a jsFiddle or jsbin example? Commented Jan 31, 2011 at 22:36
  • do you have sample data? the date sType uses the javascript Date() object, which your data might not match. Commented Jan 31, 2011 at 22:48

2 Answers 2

1

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]
Sign up to request clarification or add additional context in comments.

Comments

1

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

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

1 Comment

You're right on the positioning of the object, I missed that in my answer. From looking at the example code on the plugin page, I think the plugin is expecting 'property_name' in aoColumns, but 'property_name-asc' and 'property_name-desc' in the sort functions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.