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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Format date for link column

Thread ID:

Created:

Updated:

Platform:

Replies:

130749 May 30,2017 09:45 PM UTC Jun 1,2017 04:03 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Bernard Jurlina
Asked On May 30, 2017 09:45 PM UTC

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}?

Thanks!
B.

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

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> 
</script> 
 
@{Html.EJ().Grid<object>("Grid") 
        .Datasource((IEnumerable<object>)ViewBag.data) 
        .Columns(col => 
        { 
            col.HeaderText("Employee Image").Template("#columnTemplate").Add(); 
               . . . . .  
                   . .. .  
        }) 
        .Render(); 
} 
<script type="text/javascript"> 
    var helpers = { 
        formatDate: function (Date) { 
            return ej.format(Date, "dd.MM.yyyy HH:mm"); 
        } 
    };//helpers 
    $.views.helpers(helpers); 
    function editDnevnice(args) { 
        var val = $(args).attr("dataVal"); 
    } 
</script> 
 
 
 
Refer to the output for the code example. 
 
 
 
 
Regards,  
Seeni Sakthi Kumar S. 


Bernard Jurlina
Replied On May 31, 2017 09:08 PM UTC

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

Regards,
Bernard.

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

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.  
 
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.

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

;