I am using PrimeNG 6.0.2 with Angular 5 and I'm having issues with the Table plugin. I switched to Table because DataTable is deprecated. Now, I can't access filtered values the way I could before.
Let's say I define my table in component via ViewChild:
@ViewChild('myTable') dataTable: Table;
With DataTable, I could just access the _value property which held sorted and filtered data:
dataTable._value[index] = ...;
But now, this property hold just the sorted array, while I have to use the filteredValue property:
dataTable.filteredValue[index] = ...;
My problem with this is that the filteredValue is undefined
before any filtering, has value when the table is filtered and is null
after I remove all filter text. This yields some pretty ugly code.
Is it possible to access the current data, be it sorted, filtered or identical to the starting array? Or do I have to go with this approach?
Another way you can access the filtered values is by declaring the onFilter
event and then retrieve/store the filtered values.
// on your component class declare
onFilter(event, dt) {
this.filteredValues = event.filteredValue;
}
<p-table #dt .... (onFilter)="onFilter($event, dt)">
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