我需要有我的p-table的选择页面作为最后一页。
我能够获得我的表对象:
@ViewChild('myTable') myTable: DataTable;
ngOnInit() {
this.subService.subsUpdated.subscribe(result => {
this.fetchSubcontracts();
});
this.appForm.subAdded.subscribe(result => {
this.added = 4;
this.fetchSubs();
});
}我尝试将p-table上的[first]和[paginatorPosition]属性绑定到一个属性,但没有成功。
<p-table #myTable
[value]="subs"
sortMode="multiple"
selectionMode="single"
(onRowSelect)="onRowSelect($event)"
(onRowUnselect)="onRowUnselect($event)"
[(selection)]="selectedSub"
[columns]="columns"
dataKey="id"
[paginator]="subs.length > 0"
[rows]="5"
[first]="added"
>发布于 2018-08-11 04:43:10
first属性是要显示的第一个行的索引,而不是要显示的第一个页面的索引。
在您的表属性中,您设置了每页5行,因此如果添加等于4,您将始终停留在包含第4行的第一页。
因此,添加的内容应该类似于Math.floor(this.subs.length/5)
https://stackoverflow.com/questions/51792559
复制相似问题