beforeSend event or similar for NgGrid ?

Hi,

Within EJ1 i can find informations and samples about the beforeSend event, in order to intercept an (odata) adaptor query, to inject or modify params.

Could you show me how to preceed within EJ2 angular version ?

I am struggling a bit with this attempt, i think i'm close but i can't find the property or interface to call to change the params on live :

class CustomAdaptor extends ODataV4Adaptor {
    beforeSend(dm: any, request: any, settings: any) {
        console.dir(dm);
    }
}

Thanks !

1 Reply

RS Renjith Singh Rajendran Syncfusion Team March 21, 2018 09:33 AM UTC

Hi Jean, 

Thanks for contacting Syncfusion support. 

We have analyzed your query. We suggest you to set the parameters to the request in beforeSend event which extends from the Adaptor. You can use setRequestHeader method to set the header to request. Please refer to the following sample code . 

[component.ts] 
... 
import { DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data'; 
... 
import { Http } from '@angular/http'; 
import { Ajax } from '@syncfusion/ej2-base';  
 
class SerialNoAdaptor extends ODataV4Adaptor { 
    beforeSend(dm: DataManager, request: XMLHttpRequest, settings: Ajax): void { 
       request.setRequestHeader("Authorization", "bearer"); 
    } 
} 
 
@Component({ 
    selector: 'fetchdata', 
    templateUrl: './fetchdata.component.html' 
}) 
 
export class FetchDataComponent { 
    public data: DataManager | Object[]; 
 
    @ViewChild('grid') 
    public grid: GridComponent; 
 
    ngOnInit(): void { 
        this.data = new DataManager({ 
            url: '/Home/Data', 
            adaptor: new SerialNoAdaptor 
        }); 
    } 
} 

Please refer the documentation link below, 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon