We use a date format of d-MMM-yyyy ( format: {0:d-MMM-yyyy}, etc.. ), but I haven't had any luck getting it to sort correctly, please review my fiddle:
http://jsfiddle.net/crunchfactory/dje9n6u9/
Bug? Do I need to do something different?
Thank you,
j
14 Answers, 1 is accepted
Hello Jeff,
The problem in this case that the dates are treated as strings objects and they are compared as plain text.
A possible solution is to parse them to dates so the filtering will work as expected. Please refer to this dojo example.
Regards,Boyan Dimitrov
Telerik

Where I'm having this issue is inside the detailRow of an mvvm grid, which is also mvvm; how do I get it to see the sort function, etc..?
Hello Jeff,
Setting sortable should work out of the box. Could you please prepare sample dojo example in order to demonstrate the problem?
Regards,Boyan Dimitrov
Telerik

Hi Boyan,
Please review:
http://dojo.telerik.com/@crunchfactory/UqIKo
As you can see, it's not sorting correctly at all (note the month/year); is it the date format I'm using, or am I missing something very, very obvious here? It only appears to be sorting it as a string.
Thank you!
Hello Jeff,
As I mentioned earlier the dates in your case are treated as string objects. In order to parse them to date object please use the data source schema.parse as shown below:
schema: {
model: {
fields: {
OrderDate: {
type:
"date"
,
parse:
function
(e) {
return
new
Date(e)
}
}
}
}
},
Also please refer to the modified version of the provided dojo code http://dojo.telerik.com/@boyan.dim/aFuKO.
Regards,
Boyan Dimitrov
Telerik

Hi Boyan,
To be fair, true, I forgot to place the parse function in the dojo demo, however, have been using it inside the datasource for a mvvm detailRow;
detailRow.find(
"#userGrid"
).kendoGrid({
dataSource: {
serverPaging:
false
,
schema: {
data:
"data"
,
total:
"total"
,
model: {
fields: {
Date: {
type:
"date"
,
parse:
function
(e) {
return
new
Date(e)
}
}
}
}
},
pageSize: 10,
transport: {
read:
function
(options) {
}
},
update:
function
() {}
},
//etc...
The 'Date' in question, is inside a nested observable json array like this:
"fancyQueue"
: [{
"Approver"
:
"Smith, John"
,
"Role"
:
"Manager"
,
"Date"
:
"16-Mar-2015"
,
"Status"
:
"Approved"
}],
//etc...
It is still treating it as a string; what am I missing here?
Again, thank you very much!
Hello Jeff,
Please refer to the following dojo example. Please try to modify it in order to replicate the problem.
Regards,Boyan Dimitrov
Telerik

Hello Boyan,
Is there some way I can post my code to you privately, in a dojo or fiddle or something?
Thank you!
Hello Jeff,
One possible solution would be to open a support ticket and either attach an isolated runnable example or provide a dojo link. The communication in support tickets is completely private.
Regards,
Boyan Dimitrov
Telerik

Hi Boyan,
Thank you, very good advice, I've created a ticket for a few items, and included the entire file (however messy, lol!) to help troubleshoot.
Thank you very much!

Hi Boyan!
I've found a significant part of the issue; on the date sorting in:
http://dojo.telerik.com/@boyan.dim/UDAWE
It works great in Chrome, but the date in Firefox and Internet Explorer 9-11 returns not a number; NaN-M-0NaN
Has this been seen before? Any suggestions?
Thank you very much!

dateAdded: { type:
"date"
, parse:
function
(e) {
return
kendo.parseDate(e,
'dd-MMM-yy'
);
}},
and then:
{ field:
"dateAdded"
, title:
"Date Added"
, width:
"100px"
, type:
"dateTime"
, format:
"{0:dd-MMM-yy}"
}
Thank you Boyan
Hello Jeff,
Could you please clarify whether you have resolved the problem or the issue still persists?
Regards,Boyan Dimitrov
Telerik

Hi Boyan,
Yes, it's resolved, using the internal date parser:
return
kendo.parseDate(e,
'dd-MMM-yy'
);
Thank you!