I am supplying a date in M/d/yyyy as string in a template for the column :
But when you sort the OrderDate column, it doen't seem to sort the dates properly - it puts the column values arbitrarly. Any clues why ??
model: {
id: "MSOrderNumber",
fields: {
OrderNumber: { type: 'string' },
OrderDate_String: { type: 'string' },
columns: [
{ field: "OrderNumber", title: "Order Number" },
{ field: "OrderDate_String", title: "Order Date", template: '#= kendo.toString(ConvertStringToKendoDate(OrderDate_String), "M/d/yyyy" ) #' },
Using this little function to get a formatted Date from string
function ConvertStringToKendoDate(value)
{
var escapeRegExp = function (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
var replaceAll = function (find, replace, str) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
var find = '-';
if (value != null && value != undefined && value != '') {
value = replaceAll(find, '/', value)
value = new Date(value);
}
return value;
}
But when you sort the OrderDate column, it doen't seem to sort the dates properly - it puts the column values arbitrarly. Any clues why ??
model: {
id: "MSOrderNumber",
fields: {
OrderNumber: { type: 'string' },
OrderDate_String: { type: 'string' },
columns: [
{ field: "OrderNumber", title: "Order Number" },
{ field: "OrderDate_String", title: "Order Date", template: '#= kendo.toString(ConvertStringToKendoDate(OrderDate_String), "M/d/yyyy" ) #' },
Using this little function to get a formatted Date from string
function ConvertStringToKendoDate(value)
{
var escapeRegExp = function (str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
var replaceAll = function (find, replace, str) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
var find = '-';
if (value != null && value != undefined && value != '') {
value = replaceAll(find, '/', value)
value = new Date(value);
}
return value;
}