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

参考

相关内容

热门资讯

透视插件"来玩app... 透视插件"来玩app破解"aapoker辅助器是真的吗(果然有辅助神器)-哔哩哔哩aapoker辅助...
为了进一步"hhpo... 为了进一步"hhpoker德州有挂吗"wpk辅助插件(总是真的是有辅助软件)-哔哩哔哩;1、hhpo...
为了进一步"hhpo... 为了进一步"hhpoker智能辅助插件"拱趴大菠萝十三水作必弊(果然存在有辅助辅助器)-哔哩哔哩在进...
长期以来"wpk辅助... 长期以来"wpk辅助是什么"拱趴大菠萝挂(竟然真的是有辅助神器)-哔哩哔哩1、wpk辅助是什么有没有...
迎来新发展"wepo... 迎来新发展"wepoker破解器激活码"hhpoker德州有挂吗(总是真的有辅助修改器)-哔哩哔哩1...
连日来"wpk辅助&... 连日来"wpk辅助"wepoker插件程序激活码(其实真的有辅助辅助器)-哔哩哔哩1、wepoker...
透视总结"hhpok... 透视总结"hhpoker哪个俱乐部靠谱"wepoker透视脚本免费下载pc(真是是有辅助辅助器)-哔...
透视脚本"wepok... 透视脚本"wepoker私局辅助"hhpoker脚本(确实是真的辅助工具)-哔哩哔哩1.wepoke...
透视了解"智星德州辅... 您好,智星德州辅助译码插件靠谱吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【48527505...
现就发布提示"hhp... 现就发布提示"hhpoker是真的假的"hhpoker真的有透视吗(切实真的有辅助软件)-哔哩哔哩1...