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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to set the format for the template column in grid?

Platform: jQuery |
Control: ejGrid

This Knowledge base explains that how to set the format for the template column in Grid.


By default, in template column the value will be rendered based on the templates that we specified in the template property.

For template manipulation i.e., to set the format for the template column we have to use templateRefresh event of ejGrid.

The following code example demonstrates how to set the format for the template column using templateRefresh event of ejGrid.


1. Render the Grid Control.

<div id="Grid"></div>
    <script type="text/javascript">
        $(function () {
                // the datasource "window.gridData" is referred from jsondata.min.js
                dataSource: window.gridData,
                allowPaging: true,
                pageSettings: { pageSize: 4 },
                templateRefresh : "templateRefresh",
                columns: [
                    { headerText: "Total Values", template: '<span>{{:EmployeeID + Freight}}</span>', width: 110 },
                    { field: "OrderID", headerText: "Order ID", textAlign: ej.TextAlign.Right, width: 90 },
                    { field: "CustomerID", headerText: "Customer ID", width: 90 },




     .PageSettings(page => { page.PageSize(4); })
     .ClientSideEvents(eve => eve.TemplateRefresh("templateRefresh"))
     .Columns(col =>
        col.HeaderText("Total Values").Template("<span>{{:EmployeeID + Freight}}</span>").Width(110).Add();
        col.Field("OrderID").HeaderText("Order ID").TextAlign(TextAlign.Right).Width(90).Add();
        col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();



<ej:Grid ID="EmployeesGrid" runat="server" AllowPaging="True">
            <PageSettings PageSize="4"></PageSettings>
            <ClientSideEvents TemplateRefresh="templateRefresh" />
                <ej:Column HeaderText="Total Values" Template="<span>{{:EmployeeID + Freight}}</span>" TextAlign="Center" Width="110" />
                <ej:Column Field="OrderID" HeaderText="Order ID" TextAlign="Right" Width="90" />
                <ej:Column Field="CustomerID" HeaderText="Customer ID" Width="80" />



<ej-grid id="Grid" datasource="(IEnumerable<object>)ViewBag.dataSource" allow-paging="true" template-refresh="templateRefresh">
    <e-page-settings page-size="4"></e-page-settings>
        <e-column header-text="Total Values" width="110" template='<span>{{:EmployeeID}} + {{:Freight}}</span>'></e-column>
        <e-column field="OrderID" header-text="Order ID" text-align="Right" width="90"></e-column>
        <e-column field="CustomerID" header-text="Customer ID" width="80"></e-column>





2. In templateRefresh event we apply for the template column using ej.format method.

function templateRefresh(args) {
    var value = parseFloat($(args.cell).text()); 
    $(args.cell).text(ej.format(value, "C2"))


Formatted template column Grid

You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

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

Live Chat Icon For mobile