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

Selected row date column not displaying long date format

2 Answers 143 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vince
Top achievements
Rank 1
Vince asked on 09 May 2013, 09:54 PM
Hi I have a column in my grid that is a DateTime field with long format date e.g. Friday, May 10, 2013

This is how it is defined in the ViewModel

[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:D}")]
[Display(Name = "Visit Date")]
public DateTime VisitDate { get; set; }
The column is displayed correctly with what I want e.g. Friday, May 10, 2013 but when I get the selected row data for that column it is coming back with the following:
[17:39:18.580] VisitDate: Fri May 10 2013 00:00:00 GMT-0400 (Eastern Daylight Time)
Here is the code on the view to get the selected row.

function deleteRow() {
    var grid = $('#scheduleGrid').data('kendoGrid');
    var rows = grid.select();
    if (rows.length > 0) {
        var dataItem = grid.dataItem(rows);
        console.log("VisitDate: " + dataItem.VisitDate);
    }
}

How do I change it to get the long format date that is displayed in the grid? Any help greatly appreciated.

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 May 2013, 07:48 AM
Hi Vince,

 This is the default way JavaScript dates are converted to string. You can use the kendo.format function to format your date in the desired format.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vince
Top achievements
Rank 1
answered on 10 May 2013, 12:52 PM
Thanks Atanas, for the reply and answer. I'm not too familiar with javascript as you can see...
Tags
Grid
Asked by
Vince
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Vince
Top achievements
Rank 1
Share this question
or