I'm filtering my table with an input and am wanting to reset the table to the first page whenever the filter is updated. Right now the table shows and the filtering works but the table page doesn't reset.
Here is what I have to far:
Table:
<ngx-datatable
class='material'
[rows]='rows'
[columns]="columns"
[columnMode]="'standard'"
[headerHeight]="75"
[footerHeight]="50"
[scrollbarH]="true"
[rowHeight]="'auto'"
[limit]="5"
[selectionType]="'multiClick'"
[offset]="tableOffset"
>
</ngx-datatable>
Relevant TS:
tableOffset = 0;
updateFilter(event, seachCriteria) {
// Filtering Process...
// Whenever the filter changes I want to go back to the first page
this.tableOffset = 0;
}
Any pointers to where I'm going wrong?
EDIT So I tried setting the offset to 1 and found that resetting with this.tableOffset = 0; did work but whenever I used the arrows to navigate to a different page it will prevent that reset from taking place.
Is this a bug or am I missing something?
You have to handle the page event as well.
view
<ngx-datatable
...
[offset]="tableOffset"
(page)="onChange($event)">
</ngx-datatable>
component
updateFilter(event, seachCriteria) {
...
this.tableOffset = 0;
}
onChange(event: any): void {
this.tableOffset = event.offset;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With