ngx-datatable
ngx-datatable copied to clipboard
pageCallback called while sorting
Hi,
I am using Angular 19. I am trying to implement externalPaging and externalSorting.
But when we click on column headers to sort the data then both pageCallback and sortCallback are called. Also, pageCallback is called on page load as well automatically.
For simplicity I have hardcoded few properties of ngx-datatable in my below code.
below is a html code:
<ngx-datatable class="bootstrap" [rows]="rows" [columns]="columns" [rowHeight]="'auto'" [headerHeight]="50" [footerHeight]="50" [count]="3" [offset]="0" [limit]="5" [columnMode]="'force'" [externalPaging]="true" [externalSorting]="true" (page)="pageCallback($event)" (sort)="sortCallback($event)" > </ngx-datatable>
below is a typescript code:
`
rows = [
{ name: 'Austin', gender: 'Male', company: 'Swimlane' },
{ name: 'Dany', gender: 'Male', company: 'KFC' },
{ name: 'Molly', gender: 'Female', company: 'Burger King' }
];
columns = [{ prop: 'name' }, { name: 'Gender' }, { name: 'Company' }];
pageCallback(event: any){ console.log('paging'); }
sortCallback(event: any){ console.log('sorting'); } `
I tried everything but no luck. Please advice how to fix this issue.