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游戏安装教程,微信小程序微乐辅助器教程,普及透视(有挂方法)-哔哩哔哩1、...
脚本揭幕!wepoker永久免... 脚本揭幕!wepoker永久免费脚本,we poker辅助器v3.3(透视)一直真的是有插件(哔哩哔...
针对!wepoker私人辅助器... 针对!wepoker私人辅助器,微乐手游脚本辅助,辅助透视(揭秘有挂)-哔哩哔哩1、进入到wepok...
脚本开挂!aapoker怎么开... 您好,这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家在这款游戏中打...
透视教学!wpk辅助,微乐陕西... 透视教学!wpk辅助,微乐陕西小程序辅助,详情透视(有挂秘笈)-哔哩哔哩wpk辅助是不是有人用挂微扑...
脚本透视!德普之星透视辅助插件... 脚本透视!德普之星透视辅助插件,德普之星辅助软件(透视)好像真的有攻略(哔哩哔哩)1、下载好脚本下载...
有了最新消息!uupoker有... 有了最新消息!uupoker有透视吗,微乐陕西麻将破解,总结脚本(有挂教学)-哔哩哔哩1、uupok...
透视辅助!aapoker透视方... 透视辅助!aapoker透视方法,aapoker怎么提高中牌率(透视)其实存在有工具(哔哩哔哩);1...
透视数据!hhpoker辅助器... 透视数据!hhpoker辅助器视频,微乐家乡自建房辅助app,透视透视(有挂总结)-哔哩哔哩1、游戏...
透视揭露!wepoker破解器... 透视揭露!wepoker破解器,wepoker游戏安装教程(透视)果然是真的神器(哔哩哔哩)1、完成...