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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

My grid column template does not work.

Thread ID:

Created:

Updated:

Platform:

Replies:

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

Why my grid column template is not working

@(Html.EJ().Grid<ApplicationCore.Entities.Distributor>("TGrid")
            .Datasource(dataSource =>
            {
                dataSource.Json(Model);
                dataSource.Adaptor(AdaptorType.RemoteSaveAdaptor);
                dataSource.CrudURL(Url.Action("Crud"));
                dataSource.SerializerMode(SerializerMode.NewtonSoft);
                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>
</script>

It will render 

${ImageFilename}

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:- 

     @(Html.EJ().Grid<object>("HierarchyGrid") 
                    .Datasource((IEnumerable<object>)ViewBag.datasource 
                     .Columns(col => { 
                               col.Field("EmployeeID").HeaderText("Image").Template("#template").TextAlign(TextAlign.Right).Width(75).Add(); 
                                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> 
</script> 

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. 

Regards, 
Farveen sulthana T 


CONFIRMATION

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