【问题标题】:How to modify entered value in string filter如何修改字符串过滤器中的输入值
【发布时间】:2016-12-01 01:24:32
【问题描述】:

我的网格中有 3 列的字符串过滤器。这工作正常。在数据索引为abc 的第三列中,我想修改输入的值。

例如,如果我按 0,那么它会过滤所有具有 0 的数据。我想按 'No' 而不是 0 进行过滤。同样,我想使用 'Yes' 而不是 1 来过滤具有 1 的数据。

我的过滤器创建代码。

this.filters = new Ext.ux.grid.GridFilters({
    filters: this.filter,
    local: true,
    autoReload: false,
});
this.features = [this.filters];
this.plugins = [this.filters];

插入过滤器的代码。

gridEl.filter.push({
    type: header.getAttribute("FILTER"),
    dataIndex: header.getAttribute("DATAINDEX"),
    encode: false,
    metaID: header.getAttribute("M"),
});

感谢您的帮助。

【问题讨论】:

标签: javascript string extjs filter extjs3


【解决方案1】:

根据你的例子http://docs.sencha.com/extjs/4.2.0/extjs-build/examples/grid-filtering/grid-filter-local.html 创建您自己的 BooleanFilter 并添加您的条件。请参阅下面的我的 sn-p。

Ext.define('MyFilter.CustomBooleanFilter', {
   extend: 'Ext.ux.grid.filter.StringFilter',
   alias: 'gridfilter.customboolean',

   validateRecord : function (record) {
       var rValue = record.get(this.dataIndex),
           fValue = this.getValue();
       return rValue == fValue || rValue == (fValue == "1" || "true".indexOf(fValue.toLowerCase()) == 0 || "yes".indexOf(fValue.toLowerCase()) == 0);
    }
});

在此处查看工作演示。 https://fiddle.sencha.com/#fiddle/1f5l

如果您不是在寻找这个,请告诉我。我按照我的理解做了 编辑:但我觉得如果这是你想要的,那么使用布尔过滤器来改变你想要的文本。像是和否。它比输入更方便用户。因为你只有两个值。

【讨论】:

  • 我正在处理这个问题。我假设您的编辑已经结束。完成后我会通知您。
  • 添加了我的最后一条评论。抱歉修改了这么多。我很高兴能玩这个.... :D 。以前没见过……
  • 我正在使用字符串过滤器,因为其余列是字符串。只有这个专栏是vollean。我正在更改过滤器类型,因为它是布尔值。另外我使用的是 ext 3.4,所以无法创建别名
  • 哦...你的是 3.4...。给出的例子是 4.2。所以我在那个框架上工作。你能尝试找到 3.4 的在线示例吗?
  • 是的,我正在尝试自己的代码。非常接近解决方案。希望它会工作
猜你喜欢
  • 2015-11-16
  • 2015-12-07
  • 1970-01-01
  • 2020-05-15
  • 2021-06-05
  • 2020-03-07
  • 1970-01-01
  • 2022-06-22
  • 2020-05-21
相关资源
最近更新 更多