Passing custom HTTP headers to ASP.NET core api service and binding to grid


Hi,I am looking for the following sample (or help)

1.using angualr  custom service which call asp.net core api and binding to grid while  AUTOMATICALLY  generating the columns 
2.using WebApiAdaptor while passing custom HTTP header in the message body (not in the url) while  AUTOMATICALLY  generating the columns 

Thanks in advance

Tomer

1 Reply

MS Mani Sankar Durai Syncfusion Team January 3, 2018 12:18 PM UTC

Hi tomer, 

Thanks for contacting Syncfusion support.  

Query 1: using angular custom service which call asp.net core api and binding to grid while AUTOMATICALLY generating the columns  
    We have checked your query and found that you would like to call the API controller in ASP.NET Core from the custom service that you have created.  
Based on your requirement we have prepared a sample that can be downloaded from the below link 
Please refer the below code example 
[home.component.html] 
<ej-grid id="Grid" [dataSource]="gridData" allowPaging="true"> 
       
</ej-grid> 
 
[home.component.ts] 
import { Component, ViewEncapsulation, ViewChild } from '@angular/core'; 
import { EJComponents } from 'ej-angular2'; 
import { Http, Response } from '@angular/http'; 
 
@Component({ 
    selector: 'home', 
    templateUrl: './home.component.html' 
}) 
export class HomeComponent { 
    public gridData:any; 
    public data: any; 
    constructor(private http: Http) { 
... 
         } 
    ngOnInit() { 
       this.http.get('api/Orders')   //call the API URL 
            .subscribe(data => this.gridData = data.json());   //bound the returned data to the grid.  
    } 
} 
[OrdersController.cs] 
 
// GET: api/values 
        [HttpGet] 
        public object Get() 
        { 
... 
            if(order.Count == 0) 
            BindDataSource(); 
            var data = order.ToList(); 
            return data; 
        } 
 
From the above code example we have called the API using this.http.get method and bound the returned data from the server to the grid. 

Query 2: using WebApiAdaptor while passing custom HTTP header in the message body (not in the url) while AUTOMATICALLY generating the columns  
         We suspect that you would like to pass the value using custom headers of the DataManager. We have already discussed about this in the following Kb.   
  
 
This can be achieved using load event in grid.  
 
 
Please let us know if you need further assistance.  
 
 
Regards, 
Manisankar Durai. 
 
 
 
  



Loader.
Up arrow icon