AngularSlickgrid列过滤器不能在格式化的列数据上正常工作。
创始人
2024-10-29 16:00:49
0

问题原因是设置了 formatter 方法之后,SlickGrid 将使用 formatter 对象的返回值进行排序和过滤操作,而不是原始的数据值。因此,如果您的列数据是格式化的,那么列过滤器将无法正常工作。

为了解决这个问题,可以使用 Angular Slickgrid 提供的onSearchChangedataView.refresh方法自定义一个搜索过滤器。在这个过滤器中,我们可以自己处理筛选器输入和数据值的比较逻辑。

下面是一个示例代码:

import { Component, OnInit } from '@angular/core';
import { SlickGridConfig } from 'angular-slickgrid';
import { CustomDataView } from './custom-data-view';

@Component({
  selector: 'my-app',
  template: `
    
  `
})
export class AppComponent implements OnInit {
  columnDefinitions: any[];
  dataset: any[];
  dataView: any;
  gridOptions: SlickGridConfig = {};

  ngOnInit(): void {
    this.columnDefinitions = [
      // your column definitions here...
      {
        id: 'formattedColumn',
        name: 'Formatted Column',
        field: 'myData',
        formatter: this.customFormatter
      }
    ];

    this.dataset = [
      {
        id: 1,
        myData: '123'
      },
      {
        id: 2,
        myData: '456'
      },
      {
        id: 3,
        myData: '789'
      }
    ];
  }

  angularGridReady(angularGrid: any): void {
    const dataView = new CustomDataView();
    dataView.setItems(this.dataset);
    this.gridOptions = angularGrid.gridOptions;
    
    this.gridOptions.enableFiltering = false;
    this.gridOptions.dataView = dataView;
    this.gridOptions.enableAutoResize = true;

相关内容

热门资讯

透视透视挂!wepoker透视... 透视透视挂!wepoker透视脚本免费下载,wepoker怎么看牌型,解密教程(其实存在有挂);科技...
透视安装!wpk透视脚本,we... WePoke高级策略深度解析‌;透视安装!wpk透视脚本,wepoker免费透视脚本,插件教程(从前...
透视好牌!aapoker辅助工... 透视好牌!aapoker辅助工具存在吗,wepoker私人局可以透视,2025版教程(一直真的是有挂...
透视好友!wepoker透视脚... 1、透视好友!wepoker透视脚本安卓,佛手大菠萝辅助,解密教程(最初有挂);详细教程。2、wep...
透视实锤!wepoker免费透... 透视实锤!wepoker免费透视脚本,德州辅助工具到底怎么样,2025新版(原来真的是有挂)这是由厦...
透视游戏!aapoker辅助挂... 透视游戏!aapoker辅助挂,哈糖大菠萝怎么挂,微扑克教程(原本有挂)相信很多朋友都在电脑上玩过a...
透视私人局!wepoker透视... 透视私人局!wepoker透视版下载,wejoker免费脚本,2025新版(确实真的是有挂)1、这是...
透视讲解!wepoker免费永... 此外,数据分析德州(wepoker免费永久脚本)辅助神器app还具备辅助透视行为开挂功能,通过对客户...
透视安卓版!德普之星透视辅助软... WePoke高级策略深度解析‌;透视安卓版!德普之星透视辅助软件下载,sohoo poker辅助,切...
透视科技!wepoker透视脚... 透视科技!wepoker透视脚本下载,hhpoker是真的假的,细节揭秘(其实有挂)是由北京得wep...