We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Problem with displaying date

I have problem with your grid control. My application has a drop down list, from where I choose year. Then with ajax script I'm invoking a action that retrievs all data that have the same year value in DateTime property like that I choosed from the drop down list. The action generates an array with data, converts it to Json and sends it to the grid back. Sadly every date that I load to the grid looks so: 
I checked how the dates retrieved from the database are looking before I return the Json array from the action, and at this point everything looks fine.
This is my grid and drop down list code:

@Html.DropDownListFor(model => model.ChoosenYear, Model.YearsList, "Choose year", new { @class = "form-control", @onchange = "onDropDownChange(this.value)" })

                                                              .Columns(col =>

This is the ajax script code:

function onDropDownChange(args) {
                url: "/Controller/GetDataByYear",
                type: "POST",
                data: { year: args },
                success: function(result) {
                    var obj = $("#Grid").ejGrid("instance");

And this is my action:

public JsonResult GetDataByYear(string year)
            var selectedYear = new DateTime(Convert.ToInt32(year), 1, 1);
            var jsonResult = Json(
                _dbService.Get().Where(p =>  p.Date.Year == selectedYear.Year).Select(p => new GridObject
                    Id = p.Id,
                    Date = p.Date,
                    Title = p.Title 
           return jsonResult; // at this point Dates look normal, that means in yyyy-MM-dd format

Can you help me with this problem?

Roman Suska

1 Reply

MF Mohammed Farook J Syncfusion Team October 1, 2014 12:03 PM UTC

Hi Roman,


Thanks for using Syncfusion products.


We have analyzed the code provided by you, and achieved your requirement by using “ej.parseJSON and the column Format”.




The column format property is used to convert the user format in Grid columns. Please find the code snippet.


[In view]


@(Html.EJ().DropDownList("drpdown").ClientSideEvents(c=> c.Change("change")).Datasource(ViewBag.data))




                   .EditSettings(e => { e.AllowAdding().AllowEditing(); })

                   .ClientSideEvents(c=> c.EndEdit("EndEdit"))

        .Columns(col =>



            col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy}").Add();




Since we are using ej.parseJSON method, we need to serialize the JSON Value after AJAX post success method. ej.parseJSON method helps to serialize the JSON Value in proper way

Please find code snippet.


[in ajax post]


<script type="text/javascript">

    function change(args) {

        var res = JSON.stringify(args)


            url: "Home/Data",

            type: "POST",


            data: { data: res },

            success: function(result) {

                var obj = $("#Grid").ejGrid("instance");









[in controller]

  public ActionResult Index()


            var drpdata = new NorthwindDataContext().OrdersViews.Select(c => c.OrderDate).Distinct().ToList();

            ViewBag.data = drpdata;

            var DataSource = new NorthwindDataContext().OrdersViews.ToList();

            ViewBag.datasource = DataSource;

            return View();


        public ActionResult Data(string data)



            JavaScriptSerializer datajson = new JavaScriptSerializer();

            var obj = datajson.Deserialize<DropDownListProperties>(data);


            var jsonResult = Json(new NorthwindDataContext().OrdersViews.ToList());

            return Json(jsonResult, JsonRequestBehavior.AllowGet);






For your convenience We have created a sample and the same can be downloaded from the below link:


Sample Location:




Please let us know if have any other queries,



J.Mohammed Farook

Live Chat Icon For mobile
Up arrow icon