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

How do I bind data to headerText in grid


I'm working on angular with syncfusion.  I'm using ejs-grid.  I want to set headerText from data from json file in assets instead of directly setting string,
Is it possible to do that?

Instead setting like headerText='Scenario', I want to bind data using {{}} like below.


3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team June 3, 2019 10:27 AM UTC

Hi Yukiko, 

Greetings from Syncfusion support. 

We have prepared a sample and we have bound column’s headerText from JSON value from ts file. Please refer the below code example. 


<ejs-grid class="sortingenabled" [dataSource]='data' allowPaging='true'> 
        <ng-template ngFor let-column [ngForOf]="columns"> 
            <e-column [field]="column.field" 
                      [isPrimaryKey]="column.isPrimaryKey != null ? column.isPrimaryKey : null" 

export class AppComponent { 
    public data: Object[]; 
    public columns: any; 
    public jsonHeaderText: object[]; 
    constructor( ) { 
    public ngOnInit(): void { 
        this.data = data.slice(0,50); 
        this.jsonHeaderText = [{"OrderID":"Ordering Detail", 
      "CustomerName":"Customer Name Detail","ShipCountry":"Shipping Country", 
      "OrderDate":"Ordering Date"}]; 
        this.columns = [{ field: 'OrderID', headerText: this.jsonHeaderText[0]["OrderID"] , isPrimaryKey: true, width: 120, textAlign: 'Right' }, 
    { field: 'Freight', width: 125, format: 'C2' }, 
    { field: 'CustomerID', headerText: 'Customer ID', width: 130 }, 
    { field: 'ShipName', headerText: 'Ship Name', width: 180 }]; 

We have prepared a sample in the following stackblitz link. 

Thavasianand S. 

YI Yukiko Imazu June 3, 2019 06:36 PM UTC

Hi Thavasianand,

Thank you for your help.
We were able to achieve our requirement.


TS Thavasianand Sankaranarayanan Syncfusion Team June 4, 2019 06:23 AM UTC

Hi Yukiko, 
We are happy that the problem has been solved. 
Please get back to us if you need any further assistance.  
Thavasianand S.

Live Chat Icon For mobile
Up arrow icon