Skip to content

p-table triggers lazy loading event twice  #16182

@aabruc

Description

@aabruc

Describe the bug

My table definition looks like this:

<p-table dataKey="id" [value]="items" 
    [paginator]="true" [rowsPerPageOptions]="[10,20,30,100,1000,10000]"
    [rows]="20" [alwaysShowPaginator]="false" paginatorDropdownAppendTo="body"
    [(selection)]="selectedItems" selectionMode="multiple" [metaKeySelection]="true"
    (onRowSelect)="rowSelect()" (onRowUnselect)="rowUnselect()"
    [lazy]="true" [showLoader]="true" [filters]="filters" (onFilter)="selectedItems = []"
    [rowHover]="true" responsiveLayout="scroll">

We're faced with the issue that the combination of column filter and sorting triggers the lazy loading twice.
Sorting and then column filter works fine, sorting without column filter also.
As soon as there is a column filter in the LazyLoadingEvent, a sorting triggers twice, and therefore we have two backend calls immediately after each other.

{first: 0, rows: 20, sortField: "changeDate", sortOrder: 1,…}
	filters: {name: {value: ["abc"], matchMode: "in"}}
	first: 0
	globalFilter: null
	rows: 20
	sortField: "changeDate"
	sortOrder: 1

I found a similar ticket that contains almost the same issue with PrimeNg version 14 from February 23, still open:
#12595

Environment

Windows 11 Enterprise

Reproducer

No response

Angular version

17.3.12

PrimeNG version

17.18.6

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v20.11.1

Browser(s)

Chrome

Steps to reproduce the behavior

No response

Expected behavior

No response

Metadata

Metadata

Labels

Type: BugIssue contains a bug related to a specific component. Something about the component is not working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions