1
votes

I have a kendo MVC grid that has a bound column like below

columns.Bound(c => c.CreatedDate).Format("{0:M/d/yyyy h:mm tt}").Title("Submitted on").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains"))).Format("{0: MM/dd/yyyy HH.mm.ss}");

the column formats fine when first loading the view: 06/22/2017 15.02.00

but i have some buttons which use AJAX to post back and get back filtered data and when re-populating the grid the column looks like this: /Date(1498161720000)/

Any help?

1

1 Answers

0
votes

First off, you have two seperate .Format tags with different formats specified, which is probably causing some problems. Pick which one you want to use and try just removing the other.

If that doesn't solve the problem, I would try declaring the format using data annotations. In your model, try adding this line above the declaration of CreatedDate:

[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:M/d/yyyy h:mm tt}")] 

and then remove .Format from your column binding.

i.e. change

columns.Bound(c => c.CreatedDate).Format("{0:M/d/yyyy h:mm tt}").Title("Submitted on").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));

to

columns.Bound(c => c.CreatedDate).Title("Submitted on").Filterable(ftb => ftb.Cell(cell => cell.Operator("contains")));

and make sure you include the

using System.ComponentModel.DataAnnotations;

line at the top of your model if you don't already have it.