How can I define what is shown on the current page in the table? I want to display a chart for every row, but i want to request the data only for those items which is shown. Example if I have 400 element in the table i don't want to send a http request instantly for this 400 element(to request the data for the charts). I want to request the data only for those which one is shown.
1
votes
You can use server-side pagination/filtering. You know how to carry that out?
- wentjun
So. You can't do it on the client side? Isn't a function there for the table which one knows the displayed rows or something what I didn't noticed?
- Jánosi-Borsos Róbert
You can, but you will have to implement your own client side filtering logic. Also, you can make use of virtual scroll to minimise the load on your DOM
- wentjun
1 Answers
1
votes
you can get the data on current page by table.bodyComponent.rowIndexes. It will return a map with data on current page.
@ViewChild(DatatableComponent) table: DatatableComponent; Array.from(this.table.bodyComponent.rowIndexes.keys()) will return the data as array.
Hope it will help you.
Source: https://github.com/swimlane/ngx-datatable/issues/1494#issuecomment-408194219