Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify entered value in string filter

I have a string filter for 3 columns in my grid. This is working fine. In third column whose dataindex is abc I want to modify entered value.

For example if I press 0 then it filtered all the data which having 0. I want to press 'No' instead of 0 to filter. Similarly I want to use 'Yes' instead of 1 to filter data with 1.

My Code for creating filter.

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

Code for inserting filter.

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

Thanks for help.

like image 884
David Avatar asked Jul 27 '16 07:07

David


1 Answers

As per you example http://docs.sencha.com/extjs/4.2.0/extjs-build/examples/grid-filtering/grid-filter-local.html Create your own BooleanFilter and add you condition. See my snippet below.

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);
    }
});

See the working demo here. https://fiddle.sencha.com/#fiddle/1f5l

Let me know if you are not looking for this. I did as per what my understanding is EDIT: But I feel if this is what you want, then use Boolean Filter to change the text you want. Like Yes and No. Its more convenient for user than enter it. As you have only two values.

like image 159
Vinod Gubbala Avatar answered Oct 21 '22 05:10

Vinod Gubbala