I am using a back-end server (Java Spring) that has Pager enabled. I am loading 100 records per page on a HTTP call.
On angular2 service, it is consuming the API ca
When you have your endpoint for some entity on {endPointBase}/ng2-smart-table, where you are processing key_like request params (i.e: @Requestparam Map to spring data Example) , you can use on client side:
export class SpringDataSource extends ServerDataSource {
constructor(http: HttpClient, endPointBase: string) {
const serverSourceConf = new ServerSourceConf();
serverSourceConf.dataKey = 'content';
serverSourceConf.endPoint = endPointBase + `/ng2-smart-table`;
serverSourceConf.pagerLimitKey = 'size';
serverSourceConf.pagerPageKey = 'page';
serverSourceConf.sortFieldKey = 'sort';
serverSourceConf.totalKey = 'totalElements';
super(http, serverSourceConf);
}
protected addPagerRequestParams(httpParams: HttpParams): HttpParams {
const paging = this.getPaging();
return httpParams
.set(this.conf.pagerPageKey, (paging.page - 1).toString())
.set(this.conf.pagerLimitKey, paging.perPage.toString());
}
protected addSortRequestParams(httpParams: HttpParams): HttpParams {
const sort: {field: string, direction: string}[] = this.getSort();
sort.forEach((column) => {
httpParams = httpParams.append(this.conf.sortFieldKey, `${column.field},${column.direction}`);
});
return httpParams;
}
}