2 * @class Ext.ux.grid.filter.BooleanFilter
3 * @extends Ext.ux.grid.filter.Filter
4 * Boolean filters use unique radio group IDs (so you can have more than one!)
5 * <p><b><u>Example Usage:</u></b></p>
7 var filters = Ext.create('Ext.ux.grid.GridFilters', {
15 defaultValue: null, // leave unselected (false selected by default)
16 yesText: 'Yes', // default
17 noText: 'No' // default
22 Ext.define('Ext.ux.grid.filter.BooleanFilter', {
23 extend: 'Ext.ux.grid.filter.Filter',
24 alias: 'gridfilter.boolean',
27 * @cfg {Boolean} defaultValue
28 * Set this to null if you do not want either option to be checked by default. Defaults to false.
32 * @cfg {String} yesText
37 * @cfg {String} noText
44 * Template method that is to initialize the filter and install required menu items.
46 init : function (config) {
49 Ext.create('Ext.menu.CheckItem', {text: this.yesText, group: gId, checked: this.defaultValue === true}),
50 Ext.create('Ext.menu.CheckItem', {text: this.noText, group: gId, checked: this.defaultValue === false})];
52 this.menu.add(this.options[0], this.options[1]);
54 for(var i=0; i<this.options.length; i++){
55 this.options[i].on('click', this.fireUpdate, this);
56 this.options[i].on('checkchange', this.fireUpdate, this);
62 * Template method that is to get and return the value of the filter.
63 * @return {String} The value of this filter
65 getValue : function () {
66 return this.options[0].checked;
71 * Template method that is to set the value of the filter.
72 * @param {Object} value The value to set the filter
74 setValue : function (value) {
75 this.options[value ? 0 : 1].setChecked(true);
80 * Template method that is to get and return serialized filter data for
81 * transmission to the server.
82 * @return {Object/Array} An object or collection of objects containing
83 * key value pairs representing the current configuration of the filter.
85 getSerialArgs : function () {
86 var args = {type: 'boolean', value: this.getValue()};
91 * Template method that is to validate the provided Ext.data.Record
92 * against the filters configuration.
93 * @param {Ext.data.Record} record The record to validate
94 * @return {Boolean} true if the record is valid within the bounds
95 * of the filter, false otherwise.
97 validateRecord : function (record) {
98 return record.get(this.dataIndex) == this.getValue();