|
@Component({
selector: 'fetchdata',
templateUrl: './fetchdata.component.html',
encapsulation: ViewEncapsulation.Emulated
})
export class FetchDataComponent {
. . .
@ViewChild('grid')
public grid: GridComponent;
ngOnInit(): void {
this.data = new DataManager({
url: 'api/Orders',
adaptor: new CustomAdaptor()
});
. . .
}
}
class CustomAdaptor extends WebApiAdaptor {
public beforeSend(datamanager: DataManager, request: XMLHttpRequest, ajax: Ajax) {
ajax.successHandler = function (data:any) {
if (this.onSuccess) {
// here you can get the httpRequest and AJAX
if (this.httpRequest.statusText == "OK" && this.options.type == "POST" || this.options.type == "PUT" )) {
alert("Success");
}
this.onSuccess(data, this);
}
return data;
}
}
}
|