Hi Daniele,
Thanks for using Syncfusion support.
We have achieved your requirement “Applying a Date format for template column in Grid”using Custom Helper function. Please refer to the following code example, Help documentation,
Code example:
|
<Grid>
@Html.EJS().Grid("CommandColumn").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
. . .
col.Field("OrderDate").HeaderText("Template Column").Width("150").Template("${getDateFormat(data.OrderDate)}").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
. . .
}).AllowPaging().PageSettings(page => page.PageCount(5)).Render()
[helper function]
<script>
function getDateFormat(OrderDate) {
var intl = new ej.base.Internationalization();
var formattedDate = intl.formatDate(OrderDate, { format: 'dd/MM/yyyy' });//format the Date value
return formattedDate; //return the formatted date
}
</script>
|
We have also prepared a sample for your reference which can be download from following link,
Please let us know if you have any further assistance on this.
Regards,
Venkatesh Ayothiraman.