Grid column template

Hi,
I used the column template on a column of my grid to get a particular effect, but in doing so the column loses the formatting type curruncy ("C0") 
that I give in the html code.
Is there a way to get both?
For greater clarity I attach my code and an image of the same column with the template and without.
Thanks for your support.
Barbara Inzitari

Attachment: MyCode_6112efa8.zip

3 Replies

MF Mohammed Farook J Syncfusion Team July 27, 2018 09:23 AM UTC

HI Inzitari 

Thanks for contacting Syncfusion support. 


You can format the template column by defined the user define function of your template render. In below sample we have defined ‘format(user-defined)’ method and we can apply the format by using getNumberFormat method. Please find the code example for your reference.  
 

<script id="template" type="text/x-template"> 
    ${format(data.Freight)} 
</script> 
 
@Html.EJS().Grid("FlatGrid").DataSource((IEnumerable<object>)ViewBag.dataSource).Width("auto").Columns(col => 
{ 
    col.HeaderText("Template column").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Template("#template").Width("150").Add(); 
    . . . 
 
}).Render() 
 
<script> 
    var instance = new ej.base.Internationalization(); 
   function format(value) { 
        return instance.formatNumber(value, { format: 'C2'}); 
    }; 
</script> 



Regards, 
J Mohammed Farook 



NI nimue July 27, 2018 05:00 PM UTC

Hi Mohammed Farook, 
Thanks for your answer now everything works great.
Best regards
Barbara Inzitari


MF Mohammed Farook J Syncfusion Team July 30, 2018 08:18 AM UTC

HI Inzitari, 
 
We are happy to hear that your problem has been resolved. 

Please get back to us if you need further assistance from us. 
 
Regards, 
J Mohammed Farook 


Loader.
Up arrow icon