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.
Syncfusion Feedback

My grid column template does not work.

Thread ID:





150431 Jan 3,2020 11:54 PM UTC Jan 7,2020 12:48 PM UTC ASP.NET MVC 1
Tags: Grid
Asked On January 3, 2020 11:54 PM UTC

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 


Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On 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 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

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

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
Live Chat Icon