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

How do I bind data to headerText in grid

Thread ID:





145005 May 31,2019 08:48 PM UTC Jun 4,2019 06:23 AM UTC Angular - EJ 2 3
Tags: Grid
Yukiko Imazu
Asked On May 31, 2019 08:48 PM UTC


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.


Thavasianand Sankaranarayanan [Syncfusion]
Replied On 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. 

Yukiko Imazu
Replied On June 3, 2019 06:36 PM UTC

Hi Thavasianand,

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


Thavasianand Sankaranarayanan [Syncfusion]
Replied On 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.


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