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

My grid column template does not work.

Why my grid column template is not working

            .Datasource(dataSource =>
                dataSource.SerializerSettings(new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
            .Columns(col =>
                col.Field(c => c.Id).IsPrimaryKey(true).IsIdentity(true).Add();
                col.Field(c => c.DistributorName).Add();
                col.Field(c => c.FriendlyUrl).Add();
                col.Field(c => c.WebsiteUrl).Add();
                col.Field(c => c.ImageFilename).Template("#template").Add();
                col.Field(c => c.ListImageFilename).Add();

<script id="template" type="text/x-template">
    <a rel='nofollow' href="@Url.Content("~/${ImageFilename}")" target="_blank">${ImageFilename}</a>

It will render 


1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team January 7, 2020 12:48 PM UTC

Hi Daniel, 

Thanks for contacting Syncfusion Support. 

We have checked your query and we have prepared sample with ColumnTemplate but we are unable to reproduce the problem at our end. Refer to the code example:- 

                     .Columns(col => { 
                                col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
<script id="template" type="text/x-template"> 
    <a rel='nofollow' rel='nofollow' href="@Url.Content("~/${ImageFilename}")" target="_blank">{{:EmployeeID}}</a> 

Note:- If you want to render the FieldName values for template you need to define the FieldName inside double braces followed with Colon {{:ImageFileName }} but in your code example it was like ${ImageFileName}. So it has been rendered the same. 
Refer to the sample Link:- 
Demo and Documention Links:- 

Still faced issue, please share us the screenshot or replicate the issue in the above sample and revert us. 

Farveen sulthana T 

Live Chat Icon For mobile
Up arrow icon