PrimeNG扩展数据表中的虚拟滚动不起作用

时间:2018-12-09 11:29:03

标签: datatable primeng expander virtualscroll

我在虚拟滚动中使用primeng dataTable。 当expandableRows为true时,虚拟滚动不起作用。而lazyLoad函数从不调用-仅在存在扩展行时才调用。 这是我的代码:

HTML:

   <p-dataTable #dt [virtualScroll]="virtualScroll" [emptyMessage]="'TABLE.EMPTY_MESSAGE'|translate" #dt [rows]="rows" [paginator]="paginator"
        (onLazyLoad)="loadLazy($event)" [pageLinks]="3" [scrollable]="true" loadingIcon="fa-spinner" [editable]="editable"
        [styleClass]="paginator?'paginator': enableFilter?'scroll filter-table':'scroll'" [totalRecords]="virtualScroll?totalRecords:null"
        [globalFilter]="gb" [value]="displayList1" [lazy]="virtualScroll" [loading]="loading" resizableColumns="true" [(selection)]="selectedItem"
        (onRowDblclick)="importButton?'':onRowDblclick($event.data)" [expandableRows]="showExpander" [expandedRows]="expandedRows"
        (onRowSelect)="onrowSelect($event)" (onRowClick)="selectRow($event);onrowSelect($event)" (onRowUnselect)="onRowUnSelect($event)"
        [rowStyleClass]="rowStyleClass" [selectionMode]="(enableSelect&&!showSelectColumn)?(multiSelect?'multiple':'single'):''"
        [metaKeySelection]="false" (onHeaderCheckboxToggle)="onHeaderCheckboxToggle($event)">

类型脚本:

 loadLazy(event: LazyLoadEvent) {
if (this.dataTable && this.dataTable.el.nativeElement.querySelector(".ui-datatable-scrollable-body")&&this.dataTable.el.nativeElement.querySelector(".ui-datatable-scrollable-body").clientHeight) {
  this.rows = Math.floor(this.dataTable.el.nativeElement.querySelector(".ui-datatable-scrollable-body").clientHeight / this.dataTable.tbody.children[0].clientHeight);}
this.filters = event.filters;
this.loading = true;
setTimeout(() => {
  this.loading = false;
  if (this.displayList) {
    let list = this.displayList.filter(row => this.filterField(row, event.filters));
    this.displayList1 = list.slice(event.first, (event.first + event.rows));
    this.totalRecords = list.length;
  }
}, 250);

}

0 个答案:

没有答案