Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / examples / ux / gridfilters / filter / BooleanFilter.js
index a3f11eb..ae8982d 100644 (file)
 /*!
- * Ext JS Library 3.1.1
- * Copyright(c) 2006-2010 Ext JS, LLC
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
  * licensing@extjs.com
  * http://www.extjs.com/license
  */
-/** \r
- * @class Ext.ux.grid.filter.BooleanFilter\r
- * @extends Ext.ux.grid.filter.Filter\r
- * Boolean filters use unique radio group IDs (so you can have more than one!)\r
- * <p><b><u>Example Usage:</u></b></p>\r
- * <pre><code>    \r
-var filters = new Ext.ux.grid.GridFilters({\r
-    ...\r
-    filters: [{\r
-        // required configs\r
-        type: 'boolean',\r
-        dataIndex: 'visible'\r
-\r
-        // optional configs\r
-        defaultValue: null, // leave unselected (false selected by default)\r
-        yesText: 'Yes',     // default\r
-        noText: 'No'        // default\r
-    }]\r
-});\r
- * </code></pre>\r
- */\r
-Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {\r
-       /**\r
-        * @cfg {Boolean} defaultValue\r
-        * Set this to null if you do not want either option to be checked by default. Defaults to false.\r
-        */\r
-       defaultValue : false,\r
-       /**\r
-        * @cfg {String} yesText\r
-        * Defaults to 'Yes'.\r
-        */\r
-       yesText : 'Yes',\r
-       /**\r
-        * @cfg {String} noText\r
-        * Defaults to 'No'.\r
-        */\r
-       noText : 'No',\r
-\r
-    /**  \r
-     * @private\r
-     * Template method that is to initialize the filter and install required menu items.\r
-     */\r
-    init : function (config) {\r
-        var gId = Ext.id();\r
-               this.options = [\r
-                       new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),\r
-                       new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];\r
-               \r
-               this.menu.add(this.options[0], this.options[1]);\r
-               \r
-               for(var i=0; i<this.options.length; i++){\r
-                       this.options[i].on('click', this.fireUpdate, this);\r
-                       this.options[i].on('checkchange', this.fireUpdate, this);\r
-               }\r
-       },\r
-       \r
-    /**\r
-     * @private\r
-     * Template method that is to get and return the value of the filter.\r
-     * @return {String} The value of this filter\r
-     */\r
-    getValue : function () {\r
-               return this.options[0].checked;\r
-       },\r
-\r
-    /**\r
-     * @private\r
-     * Template method that is to set the value of the filter.\r
-     * @param {Object} value The value to set the filter\r
-     */        \r
-       setValue : function (value) {\r
-               this.options[value ? 0 : 1].setChecked(true);\r
-       },\r
-\r
-    /**\r
-     * @private\r
-     * Template method that is to get and return serialized filter data for\r
-     * transmission to the server.\r
-     * @return {Object/Array} An object or collection of objects containing\r
-     * key value pairs representing the current configuration of the filter.\r
-     */\r
-    getSerialArgs : function () {\r
-               var args = {type: 'boolean', value: this.getValue()};\r
-               return args;\r
-       },\r
-       \r
-    /**\r
-     * Template method that is to validate the provided Ext.data.Record\r
-     * against the filters configuration.\r
-     * @param {Ext.data.Record} record The record to validate\r
-     * @return {Boolean} true if the record is valid within the bounds\r
-     * of the filter, false otherwise.\r
-     */\r
-    validateRecord : function (record) {\r
-               return record.get(this.dataIndex) == this.getValue();\r
-       }\r
+/** 
+ * @class Ext.ux.grid.filter.BooleanFilter
+ * @extends Ext.ux.grid.filter.Filter
+ * Boolean filters use unique radio group IDs (so you can have more than one!)
+ * <p><b><u>Example Usage:</u></b></p>
+ * <pre><code>    
+var filters = new Ext.ux.grid.GridFilters({
+    ...
+    filters: [{
+        // required configs
+        type: 'boolean',
+        dataIndex: 'visible'
+
+        // optional configs
+        defaultValue: null, // leave unselected (false selected by default)
+        yesText: 'Yes',     // default
+        noText: 'No'        // default
+    }]
+});
+ * </code></pre>
+ */
+Ext.ux.grid.filter.BooleanFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
+       /**
+        * @cfg {Boolean} defaultValue
+        * Set this to null if you do not want either option to be checked by default. Defaults to false.
+        */
+       defaultValue : false,
+       /**
+        * @cfg {String} yesText
+        * Defaults to 'Yes'.
+        */
+       yesText : 'Yes',
+       /**
+        * @cfg {String} noText
+        * Defaults to 'No'.
+        */
+       noText : 'No',
+
+    /**  
+     * @private
+     * Template method that is to initialize the filter and install required menu items.
+     */
+    init : function (config) {
+        var gId = Ext.id();
+               this.options = [
+                       new Ext.menu.CheckItem({text: this.yesText, group: gId, checked: this.defaultValue === true}),
+                       new Ext.menu.CheckItem({text: this.noText, group: gId, checked: this.defaultValue === false})];
+               
+               this.menu.add(this.options[0], this.options[1]);
+               
+               for(var i=0; i<this.options.length; i++){
+                       this.options[i].on('click', this.fireUpdate, this);
+                       this.options[i].on('checkchange', this.fireUpdate, this);
+               }
+       },
+       
+    /**
+     * @private
+     * Template method that is to get and return the value of the filter.
+     * @return {String} The value of this filter
+     */
+    getValue : function () {
+               return this.options[0].checked;
+       },
+
+    /**
+     * @private
+     * Template method that is to set the value of the filter.
+     * @param {Object} value The value to set the filter
+     */        
+       setValue : function (value) {
+               this.options[value ? 0 : 1].setChecked(true);
+       },
+
+    /**
+     * @private
+     * Template method that is to get and return serialized filter data for
+     * transmission to the server.
+     * @return {Object/Array} An object or collection of objects containing
+     * key value pairs representing the current configuration of the filter.
+     */
+    getSerialArgs : function () {
+               var args = {type: 'boolean', value: this.getValue()};
+               return args;
+       },
+       
+    /**
+     * Template method that is to validate the provided Ext.data.Record
+     * against the filters configuration.
+     * @param {Ext.data.Record} record The record to validate
+     * @return {Boolean} true if the record is valid within the bounds
+     * of the filter, false otherwise.
+     */
+    validateRecord : function (record) {
+               return record.get(this.dataIndex) == this.getValue();
+       }
 });
\ No newline at end of file