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

How to insert a dynamic template in the column?

Hi,

How to insert a dynamic template in the column?
 

<ej-grid id="Grid" 
             datasource="ViewBag.DataSource"
             >
        <e-columns>
            <e-column field="State" header-text="State" width="70" Template="MyTemplate">
            <e-template><p>State</p></e-template>
             </e-column>
            <e-column field="NameInstance" header-text="Instance" width="80"></e-column>
            <e-column field="NameFile" header-text="Name of file" width="80"></e-column>
        </e-columns>
    </ej-grid>

Thanks

3 Replies

MS Mani Sankar Durai Syncfusion Team July 3, 2017 12:35 PM UTC

Hi Emeline 

Thanks for contacting Syncfusion support. 

We have analyzed your query and found that you would like to have template column in grid. Refer the code example of how to show the template column value in grid. 
 
<ej-grid id="FlatGrid" datasource="ViewBag.data" allow-paging="true" > 
   <e-columns> 
         <e-column field="EmployeeID" header-text="Employee ID" template="#MyTemplate" text-align="Right"  width="75"></e-column> 
      </e-columns> 
    
</ej-grid> 
<script type="text/x-jsrender" id="MyTemplate"> 
    <e-template><p>State</p></e-template> 
</script> 
 

Note: HTML templates can be specified in the Template property of the particular column as a string (html element) or ID of the template’s HTML element. You can use JsRender syntax in the template 
We have also prepared a sample that can be downloaded from the below link. 
To apply directly to the Template property in grid refer the below code example 
   <e-column field="EmployeeID" header-text="Employee ID" template="<e-template><p>State</p></e-template>" text-align="Right"  width="75"></e-column> 
       

Refer the documentation link 

Please let us know if you need further assistance 

Regards, 
Manisankar Durai. 



ED Emeline DESHAYES July 3, 2017 12:46 PM UTC

Thanks. It works.



MS Mani Sankar Durai Syncfusion Team July 4, 2017 03:41 AM UTC

Hi Emeline 

We are happy to hear that your problem has been solved. 

Please let us know if you need further assistance 

Regards, 
Manisankar Durai. 


Loader.
Up arrow icon