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

Header Template

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

1 Reply

FS Farveen Sulthana Thameeztheen Basha Syncfusion Team 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 

Live Chat Icon For mobile
Up arrow icon