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

Date format for an item in the grid

1 Answer 274 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Henry
Top achievements
Rank 1
Henry asked on 17 Aug 2012, 06:38 PM
I was trying to format the date in the grid.
The grid uses a editortemplate for editing date.
@model DateTime
@{
    
}
@Html.TextBoxFor(model => model, string.Format("{0:d}", Model), new { disabled="true" })

The date never gets formatted.
It always defaults to this format in the grid:
17 2012 13:36:07 GMT-0500 (Central Daylight Time)


On postback, this causes  ModelState to return error.

1 Answer, 1 is accepted

Sort by
0
Ryan
Top achievements
Rank 2
answered on 18 Aug 2012, 01:15 AM
Not sure about the editor template but I format allot of dates like  the column for  LastMotion bellow 
:

var grid = $('#summaryTable').kendoGrid({
        resizable: false,
        filterable: true,
        selectable: 'row',
        pageable: false,
        sortable: {  mode: 'single'},
        columns: [
                    { field: 'Name', title: 'Vehicle', width: '*' },
                    { field: 'Hours', title: 'Hours', width: '70px' },
                    { field: 'LastMotion', title: 'Last Motion', width: '180px', template: '#= kendo.toString(LastMotion,"MM/dd/yyyy hh:mm:ss") #' }
                 ],
        dataSource: ds,
        autoBind: false
    });


Tags
Grid
Asked by
Henry
Top achievements
Rank 1
Answers by
Ryan
Top achievements
Rank 2
Share this question
or