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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Formatting a shortDate/Time in the grid.

Thread ID:

Created:

Updated:

Platform:

Replies:

147524 Sep 13,2019 07:35 PM UTC Sep 16,2019 06:53 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: Grid
John Stemper
Asked On September 13, 2019 07:35 PM UTC

In the column definition of the grid I am able to format a date as follows

col.Field("CreateDate").Format("yMd").Add();

but I need to format the date/time as month/day/year hour:minutes.

I've tried some of the standard formats that I am aware of but have not been able to get any of them to work.

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On September 16, 2019 06:53 AM UTC

Hi John, 

Greetings from the Syncfusion support, 

We have validated query and we suggest you to use custom format to achieve your requirement. In the above sample, we have applied OrderDate column format as “MM/dd/yyyy”. Please refer the below code example and help documentation link for more information about custom date formatting. 

@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.datasource).Load("onLoad").Columns(col => 
{ 
    col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("EmployeeID").HeaderText("EmployeeID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("CustomerID").HeaderText("CustomerName").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("OrderDate").HeaderText("Date").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
 
}).AllowPaging().AllowSelection(true).SelectionSettings(select=>select.Type(Syncfusion.EJ2.Grids.SelectionType.Multiple)).RowSelected("rowSelected").Render() 
 
<script> 
 
    function onLoad(args) { 
        this.columns[3].format = { type: "date", format: "MM/dd/yyyy" }; 
    } 


                                          https://ej2.syncfusion.com/aspnetmvc/documentation/common/internationalization/?no-cache=1#manipulating-datetime 

Regards, 
Seeni Sakthi Kumar S 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon