Selected row date column not displaying long date format

3 posts, 1 answers
  1. Answer
    Vince
    Vince avatar
    7 posts
    Member since:
    Apr 2013

    Posted 09 May 2013 Link to this post

    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. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 10 May 2013 Link to this post

    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!
  3. Vince
    Vince avatar
    7 posts
    Member since:
    Apr 2013

    Posted 10 May 2013 Link to this post

    Thanks Atanas, for the reply and answer. I'm not too familiar with javascript as you can see...
Back to Top