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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Header Template

Thread ID:





132539 Sep 7,2017 10:07 AM UTC Sep 9,2017 04:32 PM UTC JavaScript 1
Tags: ejGrid
Anton de Gruchy
Asked On September 7, 2017 10:07 AM UTC

I want to use the same template for all my column headers through the application. What are the field names that I can use in the template to display the column name and sort direction?

if  I do this. 

it just displays {{:headerText}} in the column header

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On September 9, 2017 04:32 PM UTC

Hi Anton, 

Thanks for contacting Syncfusion Support. 

We have checked your query and achieved your requirement displaying the headerText and sort icon on headerTemplate by using “create” and “load” event of the Grid. In the “load” event of the Grid, we have enabled the headerTemplate(sort icon) by using headerTemplateID for the columns that have enabled sorting. On create event, we have prepend the headerText for the columns that has e-headertemplate class. 

Refer  to the code example:- 
<script type="text/javascript"> 
        $(function () { 
                dataSource: window.gridData,  
                 allowSorting :true, 
                 load : function (args) {  
                    for (var i = 0 ; i < this.model.columns.length; i++) {  
                        if (ej.isNullOrUndefined(this.model.columns[i].allowSorting)) {  
                            this.model.columns[i].headerTemplateID = "#datetemplate";  
                create : function(args) {  
                        var headers = this.getHeaderTable().find(".e-headercelldiv");  
                        for (var i = 0 ; i < headers.length; i++) {  
                               headers.eq(i).prepend("<span style='float:right'>" + headers.eq(i).attr("data-ej-mappingname") + "</span>")  
                isResponsive: true,  
                columns: [  
                     { field: "OrderID", headerText: "Order ID", isPrimaryKey: true, textAlign: ej.TextAlign.Right, width: 75 },                  .  . . 
         <script id="datetemplate" type="text/x-jsrender">  
          <span class="date e-headericon"></span>  

Refer to the API link :- 

Please get back to us if you need any further assistance. 


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