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

参考

相关内容

热门资讯

透视好友房!德普之星透视辅助软... 透视好友房!德普之星透视辅助软件是真的吗(透视)详细辅助wpk教程(果然是有挂)1、下载好德普之星透...
透视脚本(wepoKe)wpk... 透视脚本(wepoKe)wpk的发牌有规律吗(透视)详细辅助新2025教程;小薇(透视辅助)致您一封...
辅助透视!约局吧开挂(透视)本... 1、辅助透视!约局吧开挂(透视)本然真的是有挂(详细辅助科技教程)2、进入游戏-大厅左侧-新手福利-...
透视透视挂!wpk辅助软件(透... 透视透视挂!wpk辅助软件(透视)详细辅助我来教教你(其实真的是有挂)1、wpk辅助软件系统规律教程...
透视好友房(wePoKe)德州... 透视好友房(wePoKe)德州ai机器人辅助(透视)详细辅助切实教程;建议优先通过德州ai机器人辅助...
透视肯定!hhpoker作弊实... 透视肯定!hhpoker作弊实战视频(透视)一直存在有挂(详细辅助2025新版技巧)是一款可以让一直...
透视安卓版!wepoker辅助... 透视安卓版!wepoker辅助下载(透视)详细辅助新2025版(总是有挂)1、不需要AI权限,帮助你...
透视了解(wepOke)wpk... 透视了解(wepOke)wpk免费赛规则(透视)详细辅助黑科技教程,支持语音通讯、好友开房及战队组建...
透视黑科技!hhpoker德州... 透视黑科技!hhpoker德州作弊(透视)从前真的有挂(详细辅助软件教程);hhpoker德州作弊软...
透视玄学!智星德州有脚本吗(透... 透视玄学!智星德州有脚本吗(透视)详细辅助曝光教程(竟然是有挂)1、用户打开应用后不用登录就可以直接...