Upgrade to ExtJS 3.3.0 - Released 10/06/2010
[extjs.git] / examples / docs / source / Filter.html
diff --git a/examples/docs/source/Filter.html b/examples/docs/source/Filter.html
new file mode 100644 (file)
index 0000000..c3153cf
--- /dev/null
@@ -0,0 +1,195 @@
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.3.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+Ext.namespace('Ext.ux.grid.filter');
+
+<div id="cls-Ext.ux.grid.filter.Filter"></div>/** 
+ * @class Ext.ux.grid.filter.Filter
+ * @extends Ext.util.Observable
+ * Abstract base class for filter implementations.
+ */
+Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
+    <div id="cfg-Ext.ux.grid.filter.Filter-active"></div>/**
+     * @cfg {Boolean} active
+     * Indicates the initial status of the filter (defaults to false).
+     */
+    active : false,
+    <div id="prop-Ext.ux.grid.filter.Filter-active"></div>/**
+     * True if this filter is active.  Use setActive() to alter after configuration.
+     * @type Boolean
+     * @property active
+     */
+    <div id="cfg-Ext.ux.grid.filter.Filter-dataIndex"></div>/**
+     * @cfg {String} dataIndex 
+     * The {@link Ext.data.Store} dataIndex of the field this filter represents.
+     * The dataIndex does not actually have to exist in the store.
+     */
+    dataIndex : null,
+    <div id="prop-Ext.ux.grid.filter.Filter-menu"></div>/**
+     * The filter configuration menu that will be installed into the filter submenu of a column menu.
+     * @type Ext.menu.Menu
+     * @property
+     */
+    menu : null,
+    <div id="cfg-Ext.ux.grid.filter.Filter-updateBuffer"></div>/**
+     * @cfg {Number} updateBuffer
+     * Number of milliseconds to wait after user interaction to fire an update. Only supported 
+     * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
+     */
+    updateBuffer : 500,
+
+    constructor : function (config) {
+        Ext.apply(this, config);
+            
+        this.addEvents(
+            <div id="event-Ext.ux.grid.filter.Filter-activate"></div>/**
+             * @event activate
+             * Fires when an inactive filter becomes active
+             * @param {Ext.ux.grid.filter.Filter} this
+             */
+            'activate',
+            <div id="event-Ext.ux.grid.filter.Filter-deactivate"></div>/**
+             * @event deactivate
+             * Fires when an active filter becomes inactive
+             * @param {Ext.ux.grid.filter.Filter} this
+             */
+            'deactivate',
+            <div id="event-Ext.ux.grid.filter.Filter-serialize"></div>/**
+             * @event serialize
+             * Fires after the serialization process. Use this to attach additional parameters to serialization
+             * data before it is encoded and sent to the server.
+             * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
+             * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
+             */
+            'serialize',
+            <div id="event-Ext.ux.grid.filter.Filter-update"></div>/**
+             * @event update
+             * Fires when a filter configuration has changed
+             * @param {Ext.ux.grid.filter.Filter} this The filter object.
+             */
+            'update'
+        );
+        Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
+
+        this.menu = new Ext.menu.Menu();
+        this.init(config);
+        if(config && config.value){
+            this.setValue(config.value);
+            this.setActive(config.active !== false, true);
+            delete config.value;
+        }
+    },
+
+    <div id="method-Ext.ux.grid.filter.Filter-destroy"></div>/**
+     * Destroys this filter by purging any event listeners, and removing any menus.
+     */
+    destroy : function(){
+        if (this.menu){
+            this.menu.destroy();
+        }
+        this.purgeListeners();
+    },
+
+    <div id="prop-Ext.ux.grid.filter.Filter-init"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * initialize the filter and install required menu items.
+     * Defaults to Ext.emptyFn.
+     */
+    init : Ext.emptyFn,
+    
+    <div id="method-Ext.ux.grid.filter.Filter-getValue"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * get and return the value of the filter.
+     * Defaults to Ext.emptyFn.
+     * @return {Object} The 'serialized' form of this filter
+     * @methodOf Ext.ux.grid.filter.Filter
+     */
+    getValue : Ext.emptyFn,
+    
+    <div id="method-Ext.ux.grid.filter.Filter-setValue"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * set the value of the filter and fire the 'update' event.
+     * Defaults to Ext.emptyFn.
+     * @param {Object} data The value to set the filter
+     * @methodOf Ext.ux.grid.filter.Filter
+     */        
+    setValue : Ext.emptyFn,
+    
+    <div id="method-Ext.ux.grid.filter.Filter-isActivatable"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * return <tt>true</tt> if the filter has enough configuration information to be activated.
+     * Defaults to <tt>return true</tt>.
+     * @return {Boolean}
+     */
+    isActivatable : function(){
+        return true;
+    },
+    
+    <div id="prop-Ext.ux.grid.filter.Filter-getSerialArgs"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * get and return serialized filter data for transmission to the server.
+     * Defaults to Ext.emptyFn.
+     */
+    getSerialArgs : Ext.emptyFn,
+
+    <div id="method-Ext.ux.grid.filter.Filter-validateRecord"></div>/**
+     * Template method to be implemented by all subclasses that is to
+     * validates the provided Ext.data.Record against the filters configuration.
+     * Defaults to <tt>return true</tt>.
+     * @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(){
+        return true;
+    },
+
+    <div id="method-Ext.ux.grid.filter.Filter-serialize"></div>/**
+     * Returns the serialized filter data for transmission to the server
+     * and fires the 'serialize' event.
+     * @return {Object/Array} An object or collection of objects containing
+     * key value pairs representing the current configuration of the filter.
+     * @methodOf Ext.ux.grid.filter.Filter
+     */
+    serialize : function(){
+        var args = this.getSerialArgs();
+        this.fireEvent('serialize', args, this);
+        return args;
+    },
+
+    /** @private */
+    fireUpdate : function(){
+        if (this.active) {
+            this.fireEvent('update', this);
+        }
+        this.setActive(this.isActivatable());
+    },
+    
+    <div id="method-Ext.ux.grid.filter.Filter-setActive"></div>/**
+     * Sets the status of the filter and fires the appropriate events.
+     * @param {Boolean} active        The new filter state.
+     * @param {Boolean} suppressEvent True to prevent events from being fired.
+     * @methodOf Ext.ux.grid.filter.Filter
+     */
+    setActive : function(active, suppressEvent){
+        if(this.active != active){
+            this.active = active;
+            if (suppressEvent !== true) {
+                this.fireEvent(active ? 'activate' : 'deactivate', this);
+            }
+        }
+    }    
+});</pre>    
+</body>
+</html>
\ No newline at end of file