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
close icon

Problem with DateTime Format

VS 2013
ES 12.0.0.43


Dates are not formatting correctly in the grid. I have the following in my .cshtml file:

@(Html.EJ().Grid<Models.MyView>("MyGrid")
  .Datasource((IEnumerable<object>)ViewBag.datasource)
...
  col.Field("DueDate").HeaderText("Due Date").TextAlign(TextAlign.Center).Width(130).Format("{0:MM/dd/yyyy}").Add();
...

I've also tried without the .Format
  col.Field("DueDate").HeaderText("Due Date").TextAlign(TextAlign.Center).Width(130).Add();

Either way the output in the column is something similar to this:

/Date(1401473807766)/

I've tried defining the DueDate property two different ways as well:

        // Nullable
public DateTime? DueDate
{
get;
set;
}

and also 

        // Not Nullable
public DateTime DueDate
{
get;
set;
}

I've tried with frameworks 4.5 and 4.51 and the results are the same. Thinking is was something in my VS project I tried another project I had recently created for some simple testing, the results were the same when I tried to display a date.

Both projects were created using the Syncfusion template in VS 2013 (Syncfusion ASP.NET MVC Application) (NOT the classic version)

Thanks,

Rick


4 Replies

RT Rick Thompson May 30, 2014 07:12 PM UTC

As an example I've attached a new project using the Syncfusion MVC template.

This is what I've done to the new project:

  • Added a new file in the Models folder named TestGridModels.cs. This file contains one class and the class has two properties: Name, and HireDate.
  • Added a new View named TestGrid.cshtml containing a very simple grid with columns Name and HireDate.
  • To the Home Controller I've added a new action named TestGrid which returns a list with two items.
  • To _Layout.cshtml I added a link so the new view can be selected.
  • Removed the following NuGet packages related to Owin: Facebook, Google, MicrosoftAccount. I did this to try and get the zip file smaller, didn't help much.

Thanks,

Rick


Attachment: TestSfMVC_a252737a.zip


JS Jesus Sanchez May 30, 2014 08:15 PM UTC

The example does not work, follow out/date (1401048779457) /.

Have I too... waiting for a solution this problema

Thanks.


JS Jesus Sanchez June 1, 2014 06:15 AM UTC

Solved!.

Edit web.config and change the entry:
<appSettings>
    ......
    ......
    <add key="UnobtrusiveJavaScriptEnabled" value="false" />
</appSettings>

                   


MS Madhu Sudhanan P Syncfusion Team June 2, 2014 07:18 AM UTC

Hi Jesus,


The ASP.Net MVC Controls will render in two mode, they are

 

·         Unobtrusive mode.

·         Non-unobtrusive mode.

 

The ASP.Net MVC Controls will render in Unobtrusive mode when setting the “UnobtrusiveJavascriptEnabled” as true in web.config file.

 

<appSettings>

    . . . .

    <add key="UnobtrusiveJavaScriptEnabled" value="true" />

  </appSettings>

 

 

 We have analyzed the code snippet and suspect that this issue had arose in unobtrusive mode.

 

We confirmed “Date type column values not displayed in specified format in Unobtrusive configured project” as a defect and the fix for this issue, had been included in our Volume 1, 2014 Service Pack 1 (12.1.0.46) release itself. And hence we suggest you to upgrade to our latest Volume 1, 2014, Service Pack 2 (12.1.0.49) which is available in the below link.

 

MVC Link: https://www.syncfusion.com/account/downloads

 

The above link contains both the Volume 1, 2014 Service Pack 1 and 2 and the fix for this issue is available in both of them.

 

Please let us know if you have any queries.

 

Regards,

Madhu Sudhanan. P


Loader.
Live Chat Icon For mobile
Up arrow icon