1
我結合Cell
對象的數組的數據表PrimeNG:Angular2 + 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'));
});
}
所以,我發現了表具有reset()
方法清除排序/篩選/選擇狀態。每當URL參數更改並且新數據加載時,我都需要調用它。
但是,我怎樣才能引用dataTable並從ngOnInit()
方法中調用reset()
方法?
'進口{}數據表從 'primeng /組件/數據表/數據表';之後的' 感謝我。 – Arun
這工作,但它很糟糕,它似乎清除過濾器和其他一切。 – slashp