Whenever we use serverSide (paginate through backend) we should
debounce reloadData since it might call api calls too much times.
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
}
});
- this.count = CdTableServerSideService.getCount(resp[0]);
- this.images = images;
+ if (images.length > 0) {
+ this.count = CdTableServerSideService.getCount(resp[0]);
+ } else {
+ this.count = 0;
+ }
return images;
}
ngOnInit() {
this.localColumns = _.clone(this.columns);
+ // debounce reloadData method so that search doesn't run api requests
+ // for every keystroke
+ if (this.serverSide) {
+ this.reloadData = _.debounce(this.reloadData, 1000);
+ }
// ngx-datatable triggers calculations each time mouse enters a row,
// this will prevent that.