问题描述
Abp.io平台随附集成的ListService,简化了ngx-datatables在abp平台的Angular UI中的使用。
我遇到的问题是:
示例: Entity_A具有Entity_B的列表。 我想显示给定Entity_A的Entity_B表。
因此,我需要在此代码中以某种方式添加Entity_A的ID来触发基于此Entity_A的过滤。
const dataStreamCreator = (query) => this.dataService.getList(query);
this.list.hookToQuery(dataStreamCreator).subscribe((response) => {
this.data= response;
});
我知道我可以在获得响应(数据)时在UI端进行自定义过滤,但是在这种情况下,分页可能会成为问题。
问题是如何进行服务器端过滤。
非常感谢您的帮助!
解决方法
使用hookToQuery
ListService
时,它会为您提供当前查询(过滤器,页面,排序方向,排序列等)。您可以根据需要向查询添加任何内容。请查看以下示例。
export class MyComponent {
// Assign something to this variable somehow
someFilterValue;
data;
constructor(public list: ListService) {
const dataStreamCreator = (query) => this.dataService.getList({
...query,...this.someFilterValue
});
this.list.hookToQuery(dataStreamCreator).subscribe((response) => {
this.data= response;
});
}
}