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