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.

Format date for link column

Thread ID:





130749 May 30,2017 05:45 PM Jun 1,2017 12:03 AM ASP.NET MVC 3
Tags: Grid
Bernard Jurlina
Asked On May 30, 2017 05:45 PM

I have a link column in grid like this:
col.Field("DatumOd").HeaderText("Datum/vrijeme od").Width(110)
     .Format("<a id='editDN' rel='nofollow' href='#' onclick='editDnevnice({DnevniceID});return false;'>{DatumOd}</a>").Add();
which I'm using for oppening modal window to edit and it works just fine. 

How can I format link text {DatumOd} for example like {0:dd.MM.yyyy. HH:mm}?


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On May 31, 2017 06:21 AM

Hi Bernard,  
Thanks for contacting Syncfusion Support.  
We could see you would like to bind the hyperlink to Grid Columns. By default, Grid provides an option to place any HTML elements in the Grid cells using the Column Template concept. Refer to the following following Help Documents and Sample demo. 
Using the jsRender concept template columns will render the given data and therefore, we can use the helper functions to customize the rendering actions. In the following code example, helper function has been used in which the ej.format has been used to format the date in required format. 
<script type="text/x-jsrender" id="columnTemplate"> 
    <a id='editDN' rel='nofollow' href='#' dataval="{{:~formatDate(#data['HireDate'])}}" onclick='return editDnevnice(this);'>{HireDate}</a> 
        .Columns(col => 
            col.HeaderText("Employee Image").Template("#columnTemplate").Add(); 
               . . . . .  
                   . .. .  
<script type="text/javascript"> 
    var helpers = { 
        formatDate: function (Date) { 
            return ej.format(Date, "dd.MM.yyyy HH:mm"); 
    function editDnevnice(args) { 
        var val = $(args).attr("dataVal"); 
Refer to the output for the code example. 
Seeni Sakthi Kumar S. 

Bernard Jurlina
Replied On May 31, 2017 05:08 PM

Thanks Kumar,
excellent! The ColumnTemplate with formatDate helper is what I was looking for.


Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On June 1, 2017 12:03 AM

Hi Bernard,  
Thanks for the update. We are happy to hear that your requirement has been achieved. If you required further assistance on this, please get back to us.  
Seeni Sakthi Kumar S. 


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.