Format DateTime in Kendo UI Grid using asp.net MVC Wrapper

leodeoliveira picture leodeoliveira · Sep 10, 2013 · Viewed 64.1k times · Source

I want to build a Kendo UI Grid with format date dd//MM/yyyy. However, all questions that I found about this, it were resolved with code Format("{0:d}");. So, I have tried like a code below:

GridBoundColumnBuilder<TModel> builder = par.Bound(field.Name);

        switch (field.Type.Type)
        {
            case CType.Boolean:
                builder = builder.ClientTemplate(string.Format("<input type='checkbox' #= {0} ? checked='checked' : '' # disabled='disabled' ></input>", field.Name));
                break;
            case CType.Datetime:
                builder = builder.Format("{0:d}");
                break;
            case CType.Decimal:
            case CType.Double:
                builder = builder.Format("{0:0.00}");
                break;
        }

Another formats is works fine, just DateTime do not works.

I had this result for Datetime = /Date(1377020142000)/

Answer

Jaimin picture Jaimin · Sep 10, 2013

If you want to display datetime format in kendo grid then do this,

.Format("{0:dd/MM/yyyy}") 

Or

builder.ToString("dd/MM/yyyy");