This is a migrated thread and some comments may be shown as answers.

Filtering a date of type: 'string' as though it were type: 'date'

1 Answer 34 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Aaron
Top achievements
Rank 1
Aaron asked on 13 Oct 2020, 05:55 PM

Hello,

I am currently receiving the dates on my grid as strings and looking for a way to filter them as though they were dates. I tried simply changing the type in the schema from type: 'string' to type: 'date' and as far as the filtering goes this accomplished the goal, my problem now is that I can't seem to change the format of the dates being shown, I am only getting a full JavaScript date object showing as 'Tue Oct 13 2020 00:00:00 GMT-0700 (Pacific Daylight Time).'

Other than the format everything seems to be saving and updating as expected. I have tried simply adding format: "{0:dd-MMM-yyyy}" to the column as well as kendo.parseDate in the template. Any other possible solution I am missing?

Thank you in advance

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 15 Oct 2020, 10:24 AM

Hello Aaron,

Are you converting the string 'date' to a Date object?

Here is a Dojo example that demonstrates how the Grid behaves when we pass a string date to its column and what happens when the same date is converted to a Date object. When the date is converted to a Date object, you can see that it is correctly formatted based on the definition in the "format" property of the column's definition. 

Check the linked example and let me know if it helps you resolve the issue in the application you are working on.

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
General Discussions
Asked by
Aaron
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or