Add option to debounce typing in filter boxes
I'm submitting a ... (check one with "x")
[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35
I use a p-tree to display a very large number of nodes. It has a depth of 4 with around 11,000 child nodes. When I try to type in the filter box, the tree will just freeze for about 4-5 seconds. However, when I paste a word in the filter box it filters almost immediately (e.g. it freezes if I type 'c', but works instantly if I paste 'company').
It would be really nice to add an option to debounce typing (and preferably let us set the wait time), since this would be a simple way of improving performance when filtering through loads of data.
Is such a feature on your roadmap? Or does anyone else know how I can get around this limitation in the meantime?
Has there been an update on this issue?
Is there any work around for this? It would be awesome if there was this feature
You can implement this if you utilize rxjs debounceTime and distinctUntilChanged(). An example of something I just implemented
Markup:
<tr id="columnFilters">
<th *ngFor="let col of columns">
<input
[disabled]="loading"
pInputText
type="text"
(input)="onFilterInput($event, col)"
/>
</th>
</tr>
Component:
filterDebounceTime: number = 400;
filterTextChanged: Subject<any> = new Subject<any>();
onFilterInput($event: any, col: any) {
if (this.filterTextChanged.observers.length === 0) {
this.filterTextChanged.pipe(debounceTime(this.filterDebounceTime), distinctUntilChanged()).subscribe(query => {
this.dataTable.filter(query.$event.target.value, query.col.field, 'contains');
});
}
this.filterTextChanged.next({ $event, col });
}
Hi,
So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you reopen the issue so we can include it in our roadmap? Please don't forget to add your feedback as a comment after reopening the issue. These will be taken into account by us and will contribute to the development of this feature. Thanks a lot for your understanding!
Best Regards,