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

参考

相关内容

热门资讯

目前!红龙poker辅助工具,... 目前!红龙poker辅助工具,娱乐辅助系统,一直真的是有辅助工具(哔哩哔哩)1、任何红龙poker辅...
解密透视!拱趴大菠萝怎么开挂,... 解密透视!拱趴大菠萝怎么开挂,德州来玩辅助器(透视)一直是有辅助技巧(哔哩哔哩)1、拱趴大菠萝怎么开...
现就发布提示!wepoker可... 现就发布提示!wepoker可以开透视吗,欢乐茶馆挂有没有,真是存在有辅助工具(哔哩哔哩)1、点击下...
科普透视!竞技联盟辅助,智星德... 科普透视!竞技联盟辅助,智星德州有脚本吗(透视)都是有辅助技巧(哔哩哔哩)1、玩家可以在智星德州有脚...
今年以来!wepoker私人局... 今年以来!wepoker私人局怎么玩,哥哥打大a辅助工具,一贯是真的有辅助插件(哔哩哔哩)1、哥哥打...
了解透视!哈糖大菠萝攻略,佛手... 了解透视!哈糖大菠萝攻略,佛手在线大菠萝辅助(透视)原来是有辅助插件(哔哩哔哩)1、该软件可以轻松地...
近期!pokermaster脚... 近期!pokermaster脚本,天天爱柳州辅助,都是有辅助工具(哔哩哔哩)1、下载好天天爱柳州辅助...
专业透视!来玩app破解,德州... 专业透视!来玩app破解,德州透视脚本(透视)果然一直都是有辅助神器(哔哩哔哩)1、这是跨平台的德州...
针对!epoker透视底牌,新... 针对!epoker透视底牌,新畅游互娱辅助,切实存在有辅助技巧(哔哩哔哩)进入游戏-大厅左侧-新手福...
有消息称!德普之星辅助器app... 有消息称!德普之星辅助器app,微信小程序辅助器,确实是真的有辅助教程(哔哩哔哩)1、该软件可以轻松...