简体   繁体   中英

Angular 9 ng2-smart table

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

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',
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM