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方法即可。

参考

相关内容

热门资讯

目前!德普之星怎么开辅助,微信... 目前!德普之星怎么开辅助,微信小程序游戏破解微乐辅助,详细透视(的确有挂)-哔哩哔哩一、德普之星怎么...
脚本详细!wepoker免费脚... 脚本详细!wepoker免费脚本咨询,we poker插件(透视)其实有器(哔哩哔哩)小薇(辅助器软...
透视脚本!hh poker软件... 透视脚本!hh poker软件,淘宝的微乐辅助是真的吗,详细脚本(有挂秘籍)-哔哩哔哩1、下载好hh...
透视解密!wepoker免费透... 透视解密!wepoker免费透视脚本,wepoker辅助是真的假的(透视)真是存在有脚本(哔哩哔哩)...
出乎意料的是!wepoker可... 出乎意料的是!wepoker可以透视码,微乐如何自己建脚本,解迷透视(有挂解惑)-哔哩哔哩1、这是跨...
透视专业!wpk透视是真的假的... 透视专业!wpk透视是真的假的,wpk辅助软件(透视)一贯有插件(哔哩哔哩)能透视中分为三种模型:模...
透视好友!wejoker辅助软... 透视好友!wejoker辅助软件价格,手机微乐小程序自建房透视免费,解谜透视(有挂存在)-哔哩哔哩1...
透视透视!德普之星辅助器怎么用... 透视透视!德普之星辅助器怎么用,德普软件(透视)都是真的有教程(哔哩哔哩)辅助器是一种具有地方特色的...
透视好友!wepoker好友局... 透视好友!wepoker好友局透视,微信卡五星小程序辅助,详细透视(新版有挂)-哔哩哔哩1、每一步都...
脚本教你!德普之星透视,德普之... 脚本教你!德普之星透视,德普之星有透视辅助吗(透视)其实是有app(哔哩哔哩);1、全新机制【ai辅...