I'm binding an array of Cell
objects to a PrimeNG DataTable:
.html:
<p-dataTable [value]="_cells" [responsive]="true" [globalFilter]="gb">
<p-column field="id" header="id" sortable="true"></p-column>
<p-column field="name" header="name" sortable="true" ></p-column>
</p-dataTable>
.ts:
ngOnInit() {
var self = this;
// Capture the id in the URL
this._route.params.subscribe(params => {
self._stationId= params['id'];
this._dataService
.GetAllCells(self._stationId)
.subscribe((data:Cell[]) => this._cells = data,
error => alert(error),
() => console.log('Retrieved cells'));
});
}
So I found out the dataTable has a reset()
method to clear the sorting/filtering/selection state. I need to call it whenever the URL parameter changes and new data is being load.
But how can I reference the dataTable and call the reset()
method from inside the ngOnInit()
method?