我正在使用组件p-table
使用“Paginator”和“延迟加载”,我根据需要制作了一个搜索组件。
我试图解决过滤时的问题,并且页面索引位于另一页上。
例子:
页面索引 = 2
过滤文本 = texto.
然后,我更新表上的记录和页数。但如果结果具有更多或相同数量的索引页,则页面索引继续为 2。
我尝试更改事件的值,但它不适用。
PrimeNG 延迟加载文档:
loadData(event: LazyLoadEvent) {
//event.first = First row offset
//event.rows = Number of rows per page
//event.sortField = Field name to sort in single sort mode
//event.sortOrder = Sort order as number, 1 for asc and -1 for dec in single sort mode
//multiSortMeta: An array of SortMeta objects used in multiple columns sorting. Each SortMeta has field and order properties.
//filters: Filters object having field as key and filter value, filter matchMode as value
//globalFilter: Value of the global filter if available
this.cars = //do a request to a remote datasource using a service and return the cars that match the lazy load criteria
}
我假设您已经创建了您将在其中进行搜索的搜索组件,并且该组件将反映在 Turbo 表中。您没有使用 Turbotable 的全局过滤器。在这种情况下
您必须先重置表,然后再获取记录。
假设下面是您的表:
<p-table #tt [value]="testdata" class="test-data" [lazy]="true"
(onLazyLoad)="loadDataLazily($event)"
[paginator]="true" [rows]="3" [totalRecords]="totalRecords">
对您的表格使用选择器,例如#tt现在在你身上组件.ts file
在过滤方法中重置表格;
import { Table } from '../../../../node_modules/primeng/components/table/table';
export class TableComponent{
@ViewChild('tt') tt: Table;
filter(){
this.tt.reset();
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)