3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.ux.grid.filter.BooleanFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * Boolean filters use unique radio group IDs (so you can have more than one!)
19 * <p><b><u>Example Usage:</u></b></p>
21 var filters = Ext.create('Ext.ux.grid.GridFilters', {
29 defaultValue: null, // leave unselected (false selected by default)
30 yesText: 'Yes', // default
31 noText: 'No' // default
36 Ext.define('Ext.ux.grid.filter.BooleanFilter', {
37 extend: 'Ext.ux.grid.filter.Filter',
38 alias: 'gridfilter.boolean',
41 * @cfg {Boolean} defaultValue
42 * Set this to null if you do not want either option to be checked by default. Defaults to false.
46 * @cfg {String} yesText
51 * @cfg {String} noText
58 * Template method that is to initialize the filter and install required menu items.
60 init : function (config) {
63 Ext.create('Ext.menu.CheckItem', {text: this.yesText, group: gId, checked: this.defaultValue === true}),
64 Ext.create('Ext.menu.CheckItem', {text: this.noText, group: gId, checked: this.defaultValue === false})];
66 this.menu.add(this.options[0], this.options[1]);
68 for(var i=0; i<this.options.length; i++){
69 this.options[i].on('click', this.fireUpdate, this);
70 this.options[i].on('checkchange', this.fireUpdate, this);
76 * Template method that is to get and return the value of the filter.
77 * @return {String} The value of this filter
79 getValue : function () {
80 return this.options[0].checked;
85 * Template method that is to set the value of the filter.
86 * @param {Object} value The value to set the filter
88 setValue : function (value) {
89 this.options[value ? 0 : 1].setChecked(true);
94 * Template method that is to get and return serialized filter data for
95 * transmission to the server.
96 * @return {Object/Array} An object or collection of objects containing
97 * key value pairs representing the current configuration of the filter.
99 getSerialArgs : function () {
100 var args = {type: 'boolean', value: this.getValue()};
105 * Template method that is to validate the provided Ext.data.Record
106 * against the filters configuration.
107 * @param {Ext.data.Record} record The record to validate
108 * @return {Boolean} true if the record is valid within the bounds
109 * of the filter, false otherwise.
111 validateRecord : function (record) {
112 return record.get(this.dataIndex) == this.getValue();