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.
Unfortunately, activation email could not send to your email. Please try again.

Problem with DateTime Format

Thread ID:

Created:

Updated:

Platform:

Replies:

116474 May 30,2014 02:25 PM Jun 2,2014 03:18 AM ASP.NET MVC 4
loading
Tags: Grid
Rick Thompson
Asked On May 30, 2014 02:25 PM

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


Rick Thompson
Replied On May 30, 2014 03:12 PM

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

Jesus Sanchez
Replied On May 30, 2014 04:15 PM

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

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

Thanks.

Jesus Sanchez
Replied On June 1, 2014 02:15 AM

Solved!.

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

                   

Madhu Sudhanan P [Syncfusion]
Replied On June 2, 2014 03:18 AM

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: http://www.syncfusion.com/downloads/mvc-service-packs

 

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


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;