Good day,i have a similar table as from the link : https://www.primefaces.org/primeng/#/table/filter where i can filter the table with any column.
I want to count the current number of rows after filtering the table,i believe this can be done with a event but i have no clue where to start,can you kindly help with a guideline on how i can achieve this.
Get row count after Filter search
From the PrimeNG sample code, the slider has an on change event that calls with the #dt table reference:
The function 'onYearChange' is called on year change:
Alternately, one can attach to #dt via ViewChild:
Code: Select all
<p-table #dt [columns]="cols" [value]="cars" [paginator]="true" [rows]="10">
...
<ng-template pTemplate="header" let-columns>
...
<tr>
<th *ngFor="let col of columns" [ngSwitch]="col.field">
...
<p-slider [style]="{'width':'100%','margin-top':'8px'}" [(ngModel)]="yearFilter" [min]="1970" [max]="2010" (onChange)="onYearChange($event, dt)"></p-slider>
...
</th>
</tr>
</ng-template>
...
</p-table>
Code: Select all
export class TableFilterDemo implements OnInit {
...
onYearChange(event, dt) {
if (this.yearTimeout) {
clearTimeout(this.yearTimeout);
}
this.yearTimeout = setTimeout(() => {
dt.filter(event.value, 'year', 'gt');
}, 250);
}
}
Code: Select all
import { Component, ..., ViewChild, ... } from '@angular/core';
...
import { Table, TableModule } from 'primeng/components/table/table';
...
export class ... {
...
@ViewChild( 'dt' ) dt: Table;
...
this.dt.filterGlobal( ..., 'contains' );
...
-
- Information
-
Who is online
Users browsing this forum: No registered users and 6 guests