Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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)/

like image 734
leodeoliveira Avatar asked Sep 10 '13 12:09

leodeoliveira


People also ask

How do I change the date format in kendo grid?

{ field: "DOR", title: "Release Date", format: "{0:MM/dd/yyyy}", }, { field: "rating", title: "Rating" }, { command: ["edit", "destroy"], title: " ", width: "250px" }

What is Kendo grid?

The Kendo UI grid is a powerful widget which allows you to visualize and edit data via its table representation. It provides a variety of options about how to present and perform operations over the underlying data, such as paging, sorting, filtering, grouping, editing, etc.


1 Answers

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

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

Or

builder.ToString("dd/MM/yyyy"); 
like image 176
Jaimin Avatar answered Sep 20 '22 00:09

Jaimin