3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.ux.grid.filter.BooleanFilter
9 * @extends Ext.ux.grid.filter.Filter
10 * Boolean filters use unique radio group IDs (so you can have more than one!)
11 * <p><b><u>Example Usage:</u></b></p>
13 var filters = new Ext.ux.grid.GridFilters({
21 defaultValue: null, // leave unselected (false selected by default)
22 yesText: 'Yes', // default
23 noText: 'No' // default
28 Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
30 * @cfg {Boolean} defaultValue
31 * Set this to null if you do not want either option to be checked by default. Defaults to false.
35 * @cfg {String} yesText
40 * @cfg {String} noText
47 * Template method that is to initialize the filter and install required menu items.
49 init : function (config) {
52 new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
53 new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
55 this.menu.add(this.options[0], this.options[1]);
57 for(var i=0; i<this.options.length; i++){
58 this.options[i].on('click', this.fireUpdate, this);
59 this.options[i].on('checkchange', this.fireUpdate, this);
65 * Template method that is to get and return the value of the filter.
66 * @return {String} The value of this filter
68 getValue : function () {
69 return this.options[0].checked;
74 * Template method that is to set the value of the filter.
75 * @param {Object} value The value to set the filter
77 setValue : function (value) {
78 this.options[value ? 0 : 1].setChecked(true);
83 * Template method that is to get and return serialized filter data for
84 * transmission to the server.
85 * @return {Object/Array} An object or collection of objects containing
86 * key value pairs representing the current configuration of the filter.
88 getSerialArgs : function () {
89 var args = {type: 'boolean', value: this.getValue()};
94 * Template method that is to validate the provided Ext.data.Record
95 * against the filters configuration.
96 * @param {Ext.data.Record} record The record to validate
97 * @return {Boolean} true if the record is valid within the bounds
98 * of the filter, false otherwise.
100 validateRecord : function (record) {
101 return record.get(this.dataIndex) == this.getValue();