datatable datetime sorting locally work fine but not in server

datatable datetime sorting locally work fine but not in server

aisderuaisderu Posts: 2Questions: 0Answers: 0
edited May 2013 in General
Hi all,

I implemented a datatable in MVC3 c#. All working fine in local development machine including sorting of DateTime column.

However, when i upload it to server and access the webpage, the datatable sorting does not sort correctly for DateTime column.

Further testing, i found out that different browsers (Chrome and IE9) yield different results.

Any1 can advise the possible way of tackling this?

the following is my code:

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

$('#myDataTable').dataTable({ "bJQueryUI": true,
"sPaginationType": "full_numbers",
// aaSorting defined the column to be sorted
"aaSorting": [[2, "desc"]]
}).makeEditable({ sUpdateURL: "UpdateData",
"aoColumns":
[
numeric,
string,
{ "sType": "us_date"},
date,
string,
string

]
});
})


[/code]

Replies

  • aisderuaisderu Posts: 2Questions: 0Answers: 0
    Further testing with DataTables debug which is available at http://debug.datatables.net/,

    the data type is shown to be of string type instead of date type. While i run on local development environment using vs2010, the debugging result shown to be of date type which give correct sorting.

    It is strange as i uploaded the same copy of files into server and yet the result is not the same.

    Any1 encounter this problem b4?
This discussion has been closed.