Angular 9 ng2-smart table

225 Views Asked by At

I am using ng2-smart-table, I am trying to do server-side pagination & sorting. I am not able to get how to do it? Once I click on page number it should go to the backend. What function/method/event I have to use, when clicked on page or sort it should go to the function which calls API. Also I want to add a anchor link to one column, how to do that? If you provide me some example that will be helpful. Please help me with the solution. Thanks

1

There are 1 best solutions below

0
Juanpa On

You need to configure ServerDataSource with the names of the parameters your server uses for each purpose, after that you can deal with them in the server side.

this.dataSource = new ServerDataSource(this.http, {
  endPoint: environment.SERVICE + `your_route`,
  dataKey: 'Data',
  pagerPageKey: 'offset',
  pagerLimitKey: 'limit',
  filterFieldKey: 'query',
  sortFieldKey: 'sortby',
  sortDirKey: 'order',
  totalKey: 'Total',
});