Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / examples / ux / gridfilters / filter / StringFilter.js
index 3ed046e..44ea774 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.StringFilter\r
- * @extends Ext.ux.grid.filter.Filter\r
- * Filter by a configurable Ext.form.TextField\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: 'string',\r
-        dataIndex: 'name',\r
-        \r
-        // optional configs\r
-        value: 'foo',\r
-        active: true, // default is false\r
-        iconCls: 'ux-gridfilter-text-icon' // default\r
-        // any Ext.form.TextField configs accepted\r
-    }]\r
-});\r
- * </code></pre>\r
- */\r
-Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {\r
-\r
-    /**\r
-     * @cfg {String} iconCls\r
-     * The iconCls to be applied to the menu item.\r
-     * Defaults to <tt>'ux-gridfilter-text-icon'</tt>.\r
-     */\r
-    iconCls : 'ux-gridfilter-text-icon',\r
-\r
-    emptyText: 'Enter Filter Text...',\r
-    selectOnFocus: true,\r
-    width: 125,\r
-    \r
-    /**  \r
-     * @private\r
-     * Template method that is to initialize the filter and install required menu items.\r
-     */\r
-    init : function (config) {\r
-        Ext.applyIf(config, {\r
-            enableKeyEvents: true,\r
-            iconCls: this.iconCls,\r
-            listeners: {\r
-                scope: this,\r
-                keyup: this.onInputKeyUp\r
-            }\r
-        });\r
-\r
-        this.inputItem = new Ext.form.TextField(config); \r
-        this.menu.add(this.inputItem);\r
-        this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);\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.inputItem.getValue();\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.inputItem.setValue(value);\r
-        this.fireEvent('update', this);\r
-    },\r
-\r
-    /**\r
-     * @private\r
-     * Template method that is to return <tt>true</tt> if the filter\r
-     * has enough configuration information to be activated.\r
-     * @return {Boolean}\r
-     */\r
-    isActivatable : function () {\r
-        return this.inputItem.getValue().length > 0;\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
-        return {type: 'string', value: this.getValue()};\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
-        var val = record.get(this.dataIndex);\r
-\r
-        if(typeof val != 'string') {\r
-            return (this.getValue().length === 0);\r
-        }\r
-\r
-        return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;\r
-    },\r
-    \r
-    /**  \r
-     * @private\r
-     * Handler method called when there is a keyup event on this.inputItem\r
-     */\r
-    onInputKeyUp : function (field, e) {\r
-        var k = e.getKey();\r
-        if (k == e.RETURN && field.isValid()) {\r
-            e.stopEvent();\r
-            this.menu.hide(true);\r
-            return;\r
-        }\r
-        // restart the timer\r
-        this.updateTask.delay(this.updateBuffer);\r
-    }\r
-});\r
+/** 
+ * @class Ext.ux.grid.filter.StringFilter
+ * @extends Ext.ux.grid.filter.Filter
+ * Filter by a configurable Ext.form.TextField
+ * <p><b><u>Example Usage:</u></b></p>
+ * <pre><code>    
+var filters = new Ext.ux.grid.GridFilters({
+    ...
+    filters: [{
+        // required configs
+        type: 'string',
+        dataIndex: 'name',
+        
+        // optional configs
+        value: 'foo',
+        active: true, // default is false
+        iconCls: 'ux-gridfilter-text-icon' // default
+        // any Ext.form.TextField configs accepted
+    }]
+});
+ * </code></pre>
+ */
+Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
+
+    /**
+     * @cfg {String} iconCls
+     * The iconCls to be applied to the menu item.
+     * Defaults to <tt>'ux-gridfilter-text-icon'</tt>.
+     */
+    iconCls : 'ux-gridfilter-text-icon',
+
+    emptyText: 'Enter Filter Text...',
+    selectOnFocus: true,
+    width: 125,
+    
+    /**  
+     * @private
+     * Template method that is to initialize the filter and install required menu items.
+     */
+    init : function (config) {
+        Ext.applyIf(config, {
+            enableKeyEvents: true,
+            iconCls: this.iconCls,
+            listeners: {
+                scope: this,
+                keyup: this.onInputKeyUp
+            }
+        });
+
+        this.inputItem = new Ext.form.TextField(config); 
+        this.menu.add(this.inputItem);
+        this.updateTask = new Ext.util.DelayedTask(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.inputItem.getValue();
+    },
+    
+    /**
+     * @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.inputItem.setValue(value);
+        this.fireEvent('update', this);
+    },
+
+    /**
+     * @private
+     * Template method that is to return <tt>true</tt> if the filter
+     * has enough configuration information to be activated.
+     * @return {Boolean}
+     */
+    isActivatable : function () {
+        return this.inputItem.getValue().length > 0;
+    },
+
+    /**
+     * @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 () {
+        return {type: 'string', value: this.getValue()};
+    },
+
+    /**
+     * 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) {
+        var val = record.get(this.dataIndex);
+
+        if(typeof val != 'string') {
+            return (this.getValue().length === 0);
+        }
+
+        return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
+    },
+    
+    /**  
+     * @private
+     * Handler method called when there is a keyup event on this.inputItem
+     */
+    onInputKeyUp : function (field, e) {
+        var k = e.getKey();
+        if (k == e.RETURN && field.isValid()) {
+            e.stopEvent();
+            this.menu.hide(true);
+            return;
+        }
+        // restart the timer
+        this.updateTask.delay(this.updateBuffer);
+    }
+});