如何修改字符串过滤器中输入的值

Dav*_*vid 28 javascript string extjs filter extjs3

我的网格中有3列的字符串过滤器.这工作正常.在第三列,其dataindex是abc我想修改输入的值.

例如,如果我按0然后它过滤了所有具有0的数据.我想按'否'而不是0来过滤.同样,我想使用"是"而不是1来过滤数据1.

我的代码用于创建过滤器.

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

插入过滤器的代码.

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

感谢帮助.

Vin*_*ala 11

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

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);
    }
});
Run Code Online (Sandbox Code Playgroud)

请参阅此处的工作演示.https://fiddle.sencha.com/#fiddle/1f5l

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