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

参考

相关内容

热门资讯

透视普及"wepok... 透视普及"wepoker有辅助器吗"真是有辅助技巧(哔哩哔哩)亲,关键说明,wepoker有辅助器吗...
透视分享"hhpok... 透视分享"hhpoker可以开挂吗"其实存在有辅助技巧(哔哩哔哩)hhpoker可以开挂吗破解侠是真...
透视专业"wepok... 透视专业"wepoker好友助力码"真是真的有辅助技巧(哔哩哔哩)亲,关键说明,wepoker好友助...
透视有挂"hhpok... 透视有挂"hhpoker作必弊码"一直真的是有辅助攻略(哔哩哔哩)1、下载好hhpoker作必弊码透...
透视详细"wepok... 透视详细"wepoker有插件吗"切实是有辅助技巧(哔哩哔哩)1、wepoker有插件吗辅助器安装包...
透视揭幕"hh po... 透视揭幕"hh poker辅助有用吗"都是是真的辅助教程(哔哩哔哩)1、操作简单,无需hh poke...
透视了解"德州局怎么... 透视了解"德州局怎么透视"竟然真的有辅助app(哔哩哔哩)1、每一步都需要思考,不同水平的挑战德州局...
透视开挂"wepok... 透视开挂"wepoker如何设置透视"总是存在有辅助方法(哔哩哔哩)wepoker如何设置透视是不是...
透视详情"德普之星透... 透视详情"德普之星透视"其实有辅助工具(哔哩哔哩)1、德普之星透视免费脚本咨询教程、德普之星透视免费...
透视了解"hhpok... 透视了解"hhpoker德州牛仔视频"其实真的有辅助挂(哔哩哔哩)运hhpoker德州牛仔视频辅助工...