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

Format in Grid Column Template

Thread ID:





126101 Sep 23,2016 03:10 PM UTC Sep 27,2016 05:31 AM UTC ASP.NET MVC (Classic) 3
Tags: Grid
Asked On September 23, 2016 03:10 PM UTC

I have a grid, with a column template, and it works just fine, the issue is that I want to format de output as currency, and it has no effect

This is the only way I know to make a link column, and I have tried many ways to format the column, but none has effect. Could anyone please help me?

The template

<script type="text/x-jsrender" id="columnTemplate">
        {{if CXC > 0}}                               
            <a id="cobrar" rel='nofollow' href="CxCFilter?company=@Model.FiltroEmpresa&negocio=@Model.FiltroUnidadNegocio&semana={{:Key}}&moneda=Mexican Peso&USD=@Model.CambioUSD&EUR=@Model.CambioEUR">$ @String.Format("{0:N}", "{{CXC}}")</a>               
            $ 0.00

the grid

            .Columns(col =>
                col.Field("CXC").HeaderText("Cuentas por Cobrar").Template("#columnTemplate").TextAlign(TextAlign.Center).Width(110).Add();               

Isuriya Rajan [Syncfusion]
Replied On September 26, 2016 11:29 AM UTC

Hi Dayne,   
Thanks for contacting Syncfusion support.   
You can achieve your requirement by using the grid Templaterefresh event. This event will be triggered when you refresh the template column elements in the Grid. Here you can set the format for the corresponding cell value.   
Please refer to the below code example:   
        .Columns(col =>   
col.HeaderText("Template column").Template(true).TemplateID("#columnTemplate").TextAlign(TextAlign.Center).Width(110).Add();   
    function template(args) {       
        $(args.cell).find("a").text(ej.format(args.data.Freight, "C2"))   
<script type="text/x-jsrender" id="columnTemplate">   
    {{if Freight < 30}}   
    <a rel='nofollow' href="http://www.syncfusion.com/">{{:Freight}}</a>   
      <a rel='nofollow' href="http://js.syncfusion.com/">{{:Freight}}</a>   
Note: Here we have formatted the freight column.  
Please refer to the sample from the link attached:  http://www.syncfusion.com/downloads/support/directtrac/general/COLUMN~1-70534189.ZIP   
Isuriya R .  

Replied On September 26, 2016 02:14 PM UTC

Thanks !! This solucion works just fine. 

Isuriya Rajan [Syncfusion]
Replied On September 27, 2016 05:31 AM UTC

   Hi Dayne,

 Thanks for the update. We are happy to assist you. 

Isuriya R. 


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