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

Date column type doesn't work when data source is a datatable

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
N
Top achievements
Rank 1
N asked on 24 Sep 2012, 12:34 PM
Hi there,

I have a kendo grid which binds into  a datatable (it has to bind into a datatable as I do not know which columns i am expecting)
It seems like when binding a grid to a datatable, date columns are not being recognized as dates, and rendered as strings. So no filtering, sorting or formatting, and the date is being displayed in the json string format: /Date(1348489271318)/

The mark up is as follows:
    @{ Html.Kendo().Grid(Model.GridModel)
        .Name("Grid")
        .Columns(columns =>
        {
            foreach (System.Data.DataColumn column in Model.GridModel.Columns)
            {              
                var c = columns.Bound(column.DataType, column.ColumnName).Title(column.Caption);
             
                 if (column.ColumnName == "DateAdded")
                {                   
                    c.Format("{0:dd/MM/yyyy hh:mm}");
                 }
            }
        })

Once I change the datasource into a class model, then everything works fine, the dates are rendered as dates with the correct format, filtering and sorting.

Any ideas why column of datatype date is getting rendered as a string?
Thanks
N

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 24 Sep 2012, 12:53 PM
Hello,

if possible then post your question in below forum so may get solution AsAP.

http://www.kendoui.com/forums.aspx

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
N
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or