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

Column Template for the grid in angular 2 platform

I need a demo for grid column template in angluar 2.. I want to add image or any other custom template 
Thanks

3 Replies

JK Jayaprakash Kamaraj Syncfusion Team October 27, 2016 10:34 AM UTC

Hi Mohamed, 
 
Thank you for contacting Syncfusion support. 
 
To render the column template we suggest you to use property binding instead of passing the string value to the template attribute.   
 
Find the code example  

app.component.ts 
 
<ej-grid [allowPaging]="true" [allowSorting]="true" [dataSource]="gridData" [columns]="columns"> 
<e-columns> 
.. 
        <e-column headerText="Roles" width="80" [template]="template"></e-column> 
.. 
</ej-grid> 
 
`, 
    directives: [EJ_DIALOG_COMPONENTS, EJ_GRID_COMPONENTS, CORE_DIRECTIVES] 
}) 
export class AppComponent { 
.. 
       public template= "#columnTemp"; 
        
 
    constructor() {   
    } 
} 
 
Index.html 
 
<script type="text/x-jsrender" id="columnTemp"> 
<img style="width: 75px; height: 70px" src="Employees/{{:EmployeeID}}.png" alt="{{: EmployeeID }}" /> 
    </script> 

 
Regards, 
 
Jayaprakash K. 



RO Robert April 28, 2017 08:13 AM UTC

Hi 

I found that I can't put script template in angular template because jsrender does not see it. Is there any solution for this?

BR
Robert U.


SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team May 1, 2017 07:02 AM UTC

Hi Robert,  
 
We can mention the template tag referred to the Grid column in the Index.html of your Angular-2 application which has been discussed in our previous update. However, Grid also provide an option to assign the template to the inline template of the Grid columns. We have already discussed about this in following Help Document and Sample Demo. 
 
 
Regards,  
Seeni Sakthi Kumar S. 
 


Loader.
Up arrow icon