AngularSlickgrid多列过滤
创始人
2024-10-29 16:00:47
0
  1. 首先,在需要添加过滤器的列中增加filterable: true选项。例如:

{ id: 'title', name: 'Title', field: 'title', filterable: true, width: 220 }

  1. 在grid-options中添加enableFiltering: true选项。

const gridOptions: GridOption = { enableFiltering: true, // ... }

  1. 在组件中定义过滤器选项,包括列ID、过滤器类型、传递给过滤器的参数等。

const filterOptions = [ { columnId: 'title', type: FieldType.string, filter: MyCustomTitleFilter }, { columnId: 'duration', type: FieldType.number, filter: MyCustomDurationFilter }, // ... ];

  1. 创建自定义的过滤器组件。例如:

@Component({ selector: 'app-title-filter', template: , }) export class MyCustomTitleFilter implements Filter { private grid: any; private searchText = '';

init(args: any): void { this.grid = args.grid; }

destroy(): void { }

isTriggeredBy(column: Column): boolean { return column.id === 'title'; }

getArguments(): any { return { searchText: this.searchText }; }

onChange(event: any): void { // filter the grid } }

  1. 在grid对象上调用setFilter方法,传递过滤器选项参数。

this.grid.setFilter(filterOptions);

  1. 在onChange方法中,实现过滤器的逻辑。例如:

onChange(event: any): void { const searchString = event; const columnFilters = [];

if (searchString) { columnFilters.push({ columnId: 'title', operator: OperatorType.contains, searchTerms: [searchString] }); }

this.grid.setFilter(columnFilters); }

  1. 可以使用多个过滤器来实现多列过滤。修改filterOptions数组和onChange方法即可。

参考

相关内容

热门资讯

一分钟了解!hhpoker是正... 一分钟了解!hhpoker是正品吗,wepoker破解器激活码,总是是有挂(存在有挂)进入游戏-大厅...
推荐十款!hhpoker是真的... 推荐十款!hhpoker是真的吗,wpk辅助软件,切实有挂(有挂方式)暗藏猫腻,小编详细说明破解器有...
总算了解!pokermaste... 总算了解!pokermaster脚本,德普辅助app,都是真的有挂(有挂秘诀)1、游戏颠覆性的策略玩...
详细说明!wepoker作弊辅... 详细说明!wepoker作弊辅助,hhpoker有透视功能吗,确实是有挂(有挂方针)1、公共底牌简单...
大神推荐!wepoker透视脚... 大神推荐!wepoker透视脚本,wpk软件是真的吗,真是存在有挂(存在有挂)大神推荐!wepoke...
盘点十款!wpk有辅助器吗,w... 盘点十款!wpk有辅助器吗,wpk辅助插件,果然有挂(有挂教学)1、盘点十款!wpk有辅助器吗,wp...
发现一款!德普之星透视辅助,w... 发现一款!德普之星透视辅助,we-poker靠谱吗,切实存在有挂(真的有挂)1、玩家可以在透视最简单...
重要通知!aapoker如何设... 重要通知!aapoker如何设置胜率,wejoker内置辅助,确实是有挂(有挂存在)1、玩家可以在线...
玩家实测!wejoker辅助软... 玩家实测!wejoker辅助软件视频,如何下载wepoker安装包,其实存在有挂(有挂讲解)破解侠是...
必备攻略!微扑克辅助下载,wp... 必备攻略!微扑克辅助下载,wpk辅助哪里买,好像真的是有挂(果真有挂)1、用户打开应用后不用登录就可...