Abp.io Angular UI-具有自定义属性过滤器的ListService

问题描述

Abp.io平台随附集成的ListService,简化了ngx-datatables在abp平台的Angular UI中的使用。

我遇到的问题是:

如何使用某些自定义属性在ListService中进行过滤?

示例: 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;
      });
   }
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...