Articles in this section
Category / Section

How to display Syncfusion controls in grid columns?

4 mins read


You can display the other Syncfusion Essential JavaScript controls using template property of Grid columns.

The following code example shows how to render Syncfusion Essential JavaScript ejRating control as one of the Grid column and set the value based on the column “EmployeeID”.

We have used JSRender conditional tag “if” to set value for Rating control based on condition.

 1. Render the Grid control.


<script type="text/x-jsrender" id="columnTemplate">

     {{if EmployeeID<3}}

    <input type="text" class="rating" value="3" />

    {{else EmployeeID>2 && EmployeeID<5}}

    <input type="text" class="rating" value="3" />

    {{else EmployeeID>4}}

    <input type="text" class="rating" value="5" />





<div id="Grid"></div>
<script type="text/javascript">
    $(function () {// Document is ready.        
            dataSource: window.EmployeeView, 
            allowPaging: true,
                     columns: [
                      { headerText: "Employee Rating", template:"#columnTemplate", width: 150 },      //binding template column to grid
                        { field: "EmployeeID", headerText: "Employee ID", width: 90 },
                      { field: "FirstName", headerText: "First Name", width: 90 },
                      { field: "LastName", headerText: "Last Name", width: 90 },
                      { field: "Country", headerText: "Country", width: 80  },                      
          templateRefresh: "template",



            .Columns(col =>
                 col.HeaderText("Employee Rating").Template("#columnTemplate"). Width(100).Add();                
               col.Field("EmployeeID").HeaderText("Employee ID").Width(90).Add();                
               col.Field("FirstName"). HeaderText("First Name"). Width(90).Add();                
               col.Field("LastName").HeaderText("Last Name").Width(90).Add(); 
            .ClientSideEvents(eve=>{   eve.TemplateRefresh ("template")




namespace EJGrid.Controllers
    public class HomeController : Controller
        public ActionResult Index()
            var DataSource = EmployeeViewRepository.GetAllRecords();
   = DataSource;
            return View();








<ej:Grid ID=”Grid runat="server" AllowPaging="True" >  
            <ClientSideEvents templateRefresh="template" />
                 <ej:Column HeaderText="Employee Rating" Template="#columnTemplate" Width="150" />                
                <ej:Column Field="EmployeeID" HeaderText="Employee ID" Width="90"/>
                <ej:Column Field="FirstName" HeaderText="First Name" Width="90"/>
                <ej:Column Field="LastName" HeaderText="Last Name" Width="90"/>  
                <ej:Column Field="Country" HeaderText="Country" Width="80"/>             




public partial class _Default : Page
            protected void Page_Load(object sender, EventArgs e)
               this.Grid.DataSource = new NorthwindDataContext().EmployeeView.ToList();


2. You can render the ejRating control in Grid column using the templateRefresh event. If ej controls are rendered in templateRefresh event then it will re-render automatically, when any grid action is performed.


           function template(args){
              $(args.cell).find(".rating").ejRating({ allowReset: false });


Note: Similarly, we can bind all other Syncfusion JavaScript controls such as ejDatePicker, ejTimePicker, ejCheckBox etc as one of the column in grid.


The following output is displayed as a result of the above code example.


Figure: Grid with template column



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Please sign in to leave a comment