Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
145642 | Jul 2,2019 07:52 AM UTC | Jul 3,2019 11:09 AM UTC | Angular - EJ 2 | 1 |
![]() |
Tags: Grid |
export class AppComponent {
public data: DataManager;
public pageSettings: Object;
@ViewChild('grid')
public grid: GridComponent;
ngOnInit(): void {
this.data = new DataManager({ url: SERVICE_URI + 'api/Orders', adaptor: new customAdaptor }); // provide the customer adaptor in adaptor property
this.pageSettings = { pageCount: 3 };
}
}
class customAdaptor extends WebApiAdaptor { // create the custom adaptor by extending the default webApiAdaptor
public convertToQueryString(request: Object, query, dm: DataManager): string {
let res: string[] | string = [];
let table: string = 'table';
let tableName: string = request[table] || '';
let format: string = '$format';
delete request[table];
if (dm.dataSource.requiresFormat) {
request[format] = 'json';
}
let keys: string[] = Object.keys(request);
for (let prop of keys) {
(<string[]>res).push(prop + '=' + request[prop]);
}
res = (<string[]>res).join('&'); // default queryString
if (dm.dataSource.url && dm.dataSource.url.indexOf('?') !== -1 && !tableName) {
return (<string>res);
}
// please customize the queryString here
return res.length ? tableName + '?' + res : tableName || '';
}
} |
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.
This page will automatically be redirected to the sign-in page in 10 seconds.