【问题标题】:How to add a 'Business Year' condition to the AG Grid filter?如何向 AG Grid 过滤器添加“营业年度”条件?
【发布时间】:2022-07-06 21:04:30
【问题描述】:

我们使用 AG Grid,我可以看到在日期过滤器中我们有“本周”、“本季度”、“本月”、“今年”等。但我们的年份是从 4 月开始的营业年度到三月。如何将该选项添加到过滤器?

【问题讨论】:

    标签: javascript datagrid ag-grid ag-grid-react


    【解决方案1】:

    根据您列出的日期过滤器,我相当确定您使用的是 AdapTable - 我们的 AG Grid 插件。 如果是这样,那么您只需在 AdapTable 选项的 AdapTableQLOptions 部分中添加一个自定义谓词,并使其可用于所有日期列过滤器。 根据您的问题,这样的事情应该可以解决问题:

    adaptableQLOptions: {
      customPredicateDefs: [
        {
           id: 'business_year',
           moduleScope: ['filter'],
           columnScope: { 
             DataTypes: ['Date'] 
           },
           label: 'Business Year',
           handler: ({ value, inputs }) => {
             const businessYearStart: Date = new Date(2022, 3, 1);
             const businessYeaEnd: Date = new Date(2023, 2, 31);
             return value >= businessYearStart && value <= businessYeaEnd;
           },
        },
      ],
    }
    

    这将使该过滤器出现在所有列过滤器的快速过滤器栏下拉菜单中。 查看更多信息:https://docs.adaptabletools.com/guide/adaptable-ql-predicate-custom

    【讨论】:

      猜你喜欢
      • 2021-05-07
      • 2017-01-28
      • 2021-01-30
      • 2019-12-15
      • 1970-01-01
      • 2020-06-12
      • 2019-07-28
      • 2016-06-15
      • 1970-01-01
      相关资源
      最近更新 更多