【发布时间】:2019-02-15 22:46:39
【问题描述】:
我使用了一个带有 2 个tabPanels 的 tabview,每个都包含一个数据表。
考虑一下,Tab 1 数据表有 100 行,一个页面只显示 10 行,而 Tab 2 有一个数据表,只有 3 行数据并且没有分页(数据是延迟加载的)。
现在,如果我在 Tab1 中单击 datatable 的第 3 页,则会根据需要加载数据。但是,如果我现在自动单击选项卡 2,即使 datatable 应该刷新, event.first 也会设置在第 3 页。
我在我的网格和我的 tabPanel 中使用延迟加载。我还在tabPanel 中设置了[cache]="false"。
如何在每次点击标签时重置数据表?
<p-tabView>
<p-tabPanel header="Work Queue" [cache]="false">
<ng-template pTemplate="content">
<p>
<p-dataTable selectionMode="single" (onRowSelect)="onRowSelect($event)" [(selection)]="selecteditemWQ" [value]="searchDocResults"
[rows]="10" [paginator]="true" [(first)]="first"
[lazy]="true" (onLazyLoad)="loadData($event)" [totalRecords]="totalRecordsCount"
scrollHeight="5px" [loading]="loading" emptyMessage="No Records Found." rowHover="true">
<p-column field="DocumentName" header="Document Name" styleClass="wordbreak"
[style]="{'width':'200px','overflow':'visible'}"
[sortable]="true" [filter]="true" filterMatchMode="contains">
</p-column>
</p-dataTable>
</p>
</ng-template>
</p-tabPanel>
<p-tabPanel header="My Documents" [cache]="false">
<ng-template pTemplate="myDocs">
<p>
<p-dataTable [value]="searchUserDocResults" [rows]="10" [paginator]="true" [(first)]="first"
[lazy]="true" (onLazyLoad)="loadDataMyDocs($event)" [totalRecords]="totalRecordsCount"
scrollHeight="5px" [loading]="loading" emptyMessage="No Records Found." rowHover="true"
selectionMode="single" (onRowSelect)="onRowSelect($event)" [(selection)]="selecteditemWQ">
<p-column field="DocumentNumber" header="Document Number" styleClass="wordbreak"
[style]="{'width':'150px','overflow':'visible'}" [sortable]="true" [filter]="true"
filterMatchMode="contains">
</p-column>
</p-dataTable>
</p>
</ng-template>
</p-tabPanel>
</p-tabView>
【问题讨论】:
标签: angular pagination primeng primeng-datatable