Hi,
I also faced this problem, I just customized the script which are given, Now it's working fine so please try this solution, i hope it will work out.
In aspx page :Add a
type property for which field you wanna sort
{name : 'DateOfJoining',type:'date' },In gt_grid_all.js :convert:function(_,$){
switch($){
case "int":
return parseInt(_);
case "float":
return parseFloat(_);
case "date":
return Date.parseDate(_,'%d-%M-%y');
default:
return _;
}Include Date.parseDate function along with parameters respectively Date and Format which you want.
return Date.parseDate(_,'%d-%M-%y');In calendar.js :Modify the function like this
Date.parseDate = function(str, fmt) {
var today = new Date();
var y = 0;
var m = -1;
var d = 0;
var a = str.split(/\W+/);
var b = fmt.match(/%./g);
var i = 0, j = 0;
var hr = 0;
var min = 0;
for (i = 0; i < a.length; ++i) {
if (!a)
continue;
switch (b) {
case "%d":
case "%e":
d = parseInt(a, 10);
break;
case "%M":
switch(a)
{
case "Jan":
m=1;break;
case "Feb":
m=2;break;
case "Mar":
m=3;break;
case "Apr":
m=4;break;
case "May":
m=5;break;
case "Jun":
m=6;break;
case "Jul":
m=7;break;
case "Aug":
m=8;break;
case "Sep":
m=9;break;
case "Oct":
m=10;break;
case "Nov":
m=11;break;
default:
m=12; break;
}
break;
case "%Y":
case "%y":
y = parseInt(a, 10);
(y < 100) && (y += (y > 29) ? 1900 : 2000);
break;
case "%b":
case "%B":
for (j = 0; j < 12; ++j) {
if (Calendar._MN[j].substr(0, a.length).toLowerCase() == a.toLowerCase()) { m = j; break; }
}
break;
case "%H":
case "%I":
case "%k":
case "%l":
hr = parseInt(a, 10);
break;
case "%P":
case "%p":
if (/pm/i.test(a) && hr < 12)
hr += 12;
else if (/am/i.test(a) && hr >= 12)
hr -= 12;
break;
case "%M":
min = parseInt(a, 10);
break;
}
}
if (isNaN(y)) y = today.getFullYear();
if (isNaN(m)) m = today.getMonth();
if (isNaN(d)) d = today.getDate();
if (isNaN(hr)) hr = today.getHours();
if (isNaN(min)) min = today.getMinutes();
if (y != 0 && m != -1 && d != 0)
return new Date(y, m, d, hr, min, 0);
y = 0; m = -1; d = 0;
for (i = 0; i < a.length; ++i) {
if (a.search(/[a-zA-Z]+/) != -1) {
var t = -1;
for (j = 0; j < 12; ++j) {
if (Calendar._MN[j].substr(0, a.length).toLowerCase() == a.toLowerCase()) { t = j; break; }
}
if (t != -1) {
if (m != -1) {
d = m+1;
}
m = t;
}
} else if (parseInt(a, 10) <= 12 && m == -1) {
m = a-1;
} else if (parseInt(a, 10) > 31 && y == 0) {
y = parseInt(a, 10);
(y < 100) && (y += (y > 29) ? 1900 : 2000);
} else if (d == 0) {
d = a;
}
}
if (y == 0)
y = today.getFullYear();
if (m != -1 && d != 0)
return new Date(y, m, d, hr, min, 0);
return today;
};In calendar-setup.js :Change the format like this wherever applicable,
param_default("ifFormat", "%d-%M-%y");
param_default("daFormat", "%d-%M-%y");Also this,
var ds = d.print("%Y%m%d");Try this solution if you any doubt on this indeed Just mail me on
bharathi.net@gmail.comThank You.
