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

Problem formatting date value in grid

Thread ID:





143497 Mar 22,2019 04:50 PM UTC Apr 9,2019 05:57 AM UTC ASP.NET MVC - EJ 2 7
Tags: Grid
Juan José
Asked On March 22, 2019 04:50 PM UTC


I have a grid:
@Html.EJS().Grid("grdBeneficiarios").DataSource(dataManager => { dataManager.Json(Model.ToArray()).InsertUrl("/Contrato/AgregarBeneficiario").RemoveUrl("/Contrato/EliminarBeneficiario").UpdateUrl("/Contrato/ActualizarBeneficiario").Adaptor("RemoteSaveAdaptor");}).ActionBegin("actionBegin").Columns(col =>
    col.Field("IdTiposIdentificacion").HeaderText("Tipo id").ForeignKeyField("IdTiposIdentificacion").ForeignKeyValue("Nombre").DataSource((List<TipoIdViewModel>)PersonaServices.GetTiposId()).Add();
    col.Field("NumeroId").HeaderText("Numero id").Add();
    col.Field("PrimerNombre").HeaderText("Primer nombre").Visible(false).Add();
    col.Field("SegundoNombre").HeaderText("Segundo nombre").Visible(false).Add();
    col.Field("PrimerApellido").HeaderText("Primer apellido").Visible(false).Add();
    col.Field("SegundoApellido").HeaderText("Segundo apellido").Visible(false).Add();
    col.Field("IdSede").HeaderText("Sede").ForeignKeyField("IdSede").ForeignKeyValue("Nombre").DataSource((List<SedeViewModel>)ContratoServices.GetSedes().FindAll(s => s.Habilitado)).Add();
    col.Field("WelcomeDay").HeaderText("Welcome day").Format("MM/dd/yyyy hh:mm").EditType("datetimepickeredit").Add();
    col.HeaderText("Enviar email").Width("160").Commands(comandos).Add();
}).Locale("es-CO").DataBound("dataBind").Load("load").EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Dialog); }).Toolbar(toolbarItems).Render()

But no data is displayed, except when I delete the .Format option for the "WelcomeDay" column. The problem is that the value showed is: 
Fri Mar 22 2019 09:00:00 GMT-0500 (hora estándar de Colombia)
is too long!.

Madhu Sudhanan P [Syncfusion]
Replied On March 25, 2019 05:55 AM UTC

Hi Juan, 

Thanks for contacting Syncfusion support. 

You need to format the date value as follows with your own format value. 

col.Field("WelcomeDay").HeaderText("Welcome day").Format(new { type = "dateTime", format="MM/dd/yyyy hh:mm"}) 

Please refer to the below documentation link. 

Madhu Sudhanan P 

Juan José
Replied On March 25, 2019 11:11 PM UTC


Thanks so much. Now it is working but, now I have the same problem with the grid using Javascript.
My code is like the sample in documentation in https://ej2.syncfusion.com/javascript/documentation/grid/columns/#date-formatting :

columns: [
                    { field: "IdBeneficiario", isPrimaryKey: true, isIdentity: true, visible: false },
                    { field: "NumeroId", headerText: "Numero id" },
                    { field: "PrimerNombre", headerText: "Primer nombre", visible: false },
                    { field: "SegundoNombre", headerText: "Segundo nombre", visible: false },
                    { field: "Email", headerText: "Email" },
                    { field: "WelcomeDay", headerText: "Welcome day", format:{ type:"dateTime", format:"yyyy/MM/dd hh:mm a" }, editType: "datetimepickeredit"},

With the format included, no rows are shown but, if I delete the format, all rows are shown
I don´t know what is wrong, I am writting in the same way as the sample in documentation.

Thanks for your help,
Kind regards,

Pavithra Subramaniyam [Syncfusion]
Replied On March 26, 2019 09:07 AM UTC

Hi Juan, 

Thanks for your Update. 

We have analyzed your query but we are unable to reproduce the reported issue at our end. So please provide the below information for us, it will help us provide a better solution as soon as possible, 

  1. Please share the Sample data of your Grid.
  2. Please share you full grid code sample?
  3. Please share grid package version details?
  4. Could you please try to reproduce the reported issue in the below provided sample?
  5. Please try to bind ‘actionFailure’ event in Grid and share the argument of that event

Please get back to us for further assistance. 
Pavithra S. 

Juan José
Replied On April 6, 2019 04:46 PM UTC


I am still facing this issue with javascript.

I am attaching the info requested:
DataSource.PNG shows the data used to feed the grid.
actionFailure.PNG shows the action failure args.
GridCode.txt has the whole grid code.

Thanks for your help, kind regards

Juan J.

Attachment: FormatDate_d6193346.zip

Hariharan J V [Syncfusion]
Replied On April 8, 2019 11:08 AM UTC

Hi Juan, 

Thanks for the provided details. 

From your screenshot, we found that date column value is in JSON string format. But it is necessary to provide the JSON data to JsonAdaptor instead of this JSON string. So we suggest to parse this JSON string to JSON data before providing it to Grid. Please refer the following code snippet, 

var data = new ej.data.DataManager(window.orderData).executeLocal(new ej.data.Query().take(15)); 
    var grid = new ej.grids.Grid({ 
        dataSource: ej.data.DataUtil.parse.parseJson(data), 


Juan José
Replied On April 8, 2019 01:29 PM UTC

Thanks so much, it is woring now.
Kind regards,
Juan J.

Hariharan J V [Syncfusion]
Replied On April 9, 2019 05:57 AM UTC

Hi Juan, 
Thanks for your update.  
We are happy to hear that the provided solution helped you.   
Please contact us if you need any further assistance. As always, we will be happy to assist you.   


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