28

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.

Yosvel Quintero
  • 18,669
  • 5
  • 37
  • 46
David
  • 4,266
  • 8
  • 34
  • 69

1 Answers1

11

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.

Vinod Gubbala
  • 676
  • 6
  • 16
  • I am working on this. I assume your edit is over. I will notify you once I am done. – David Aug 12 '16 at 06:22
  • Added my last comment. Sorry for so many edits. I am just excited to play with this.... :D . Never saw those before.... – Vinod Gubbala Aug 12 '16 at 06:26
  • I am using string filter because rest other column is string. only this column is vollean. I am changing filter type for this is as Boolean. Also I am using ext 3.4 so can not create alias – David Aug 12 '16 at 06:34
  • Ohh... Yours is 3.4.... The example given was 4.2. So I worked on that framework. Can you try to find an online example for 3.4? – Vinod Gubbala Aug 12 '16 at 06:38
  • Ya, I am trying in my code itself. Very close to solution. Hope it will work – David Aug 12 '16 at 06:41
  • Hope it works. You can always share a small example in fiddle and I can help you in solving it. – Vinod Gubbala Aug 12 '16 at 06:49
  • Your return statement is based on yes and no or true and false – David Aug 12 '16 at 07:05
  • As I don't know what exactly you want. You can convert that condition based on your requirement – Vinod Gubbala Aug 12 '16 at 07:15
  • One last question. filter type of the column will be string or Boolean. Because when I am setting Boolean I am getting checkbox of "Yes" and "No". – David Aug 12 '16 at 07:26
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120766/discussion-between-user6474292-and-vinod-gubbala). – David Aug 12 '16 at 07:51