Angular Datatable: Have search fields. will do select and will get datatable population. First time working fine, once we click with some other data and click, API response coming but data is not updated in the table. Could you please suggest me how to destroy/reinitialize table for next click. Here is the sample code I written
//html table
<table
datatable
[dtOptions]="dtOptions"
[dtTrigger]="dtTrigger"
class="row-border hover">
</table>
//datatable properties
this.dtOptions = {
data: jsonData,
pagingType: "full_numbers",
pageLength: 10,
scrollCollapse: true,
processing: true,
fixedHeader: true,
destroy: true,
columns: [
{data: 'test1'},
{data: 'test2'},
{data: 'test3'},
]
}
//http.get for response
this.http
.get(url, {params})
.subscribe((res) => {
this.results = res;
this.dtTrigger.next();
}
//Table destroy
ngOnDestroy(): void {
this.dtTrigger.unsubscribe();
}
this.http.getis in ngOnInit ?