Skip to content

Instantly share code, notes, and snippets.

@hbekkouche
Created February 11, 2024 16:25
Show Gist options
  • Save hbekkouche/295793ee85ae3a38ec2d6e8a7a67ca50 to your computer and use it in GitHub Desktop.
Save hbekkouche/295793ee85ae3a38ec2d6e8a7a67ca50 to your computer and use it in GitHub Desktop.
Primeng Lazy load
load(event: TableLazyLoadEvent | undefined) {
let url = 'search=';
if (this.search.email) {
url = url + ',email~' + (this.search.email || '');
}
if (this.search.firstPhone) {
url = url + ',firstPhone~' + (this.search.firstPhone || '');
}
if (this.search.lastName) {
url = url + ',lastName~' + (this.search.lastName || '');
}
if (this.search.firstName) {
url = url + ',firstName~' + (this.search.firstName || '');
}
if (this.search.badge) {
url = url + ',badge~' + (this.search.badge || '');
}
if (this.search.state) {
url = url + ',state.nameAr~' + (this.search.state.nameAr || '');
}
if (this.search.job) {
url = url + ',job.nameAr~' + (this.search.job.nameAr || '');
}
url = url + '&page=' + ((event?.first ?? 0) / (event?.rows ?? 1)) +
'&size=' + (event?.rows || this.size) +
'&sortBy=' + (event?.sortField || 'id') + '&sortDir=' + ((event?.sortOrder!) > 0 ? 'asc' : 'desc');
this.loading = true;
this.adherentService.findAll(url).subscribe((res) => {
if (res.code === '201') {
this.adherents = res.data.content;
this.totalRecords = res.data.totalElements;
this.loading = false;
} else {
}
});
}
@Override
public ResponseEntity<ResultResponse> search(@RequestParam(value = "search", required = false) String search,
@RequestParam(value = "page", required = false) String page,
@RequestParam(value = "size", required = false) String size,
@RequestParam(value = "sortBy", required = false) String sortBy,
@RequestParam(value = "sortDir", required = false) String sortDir) {
return super.search(search, page, size, sortBy, sortDir);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment