3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
15 Ext.namespace('Ext.ux.grid.filter');
17 <div id="cls-Ext.ux.grid.filter.Filter"></div>/**
18 * @class Ext.ux.grid.filter.Filter
19 * @extends Ext.util.Observable
20 * Abstract base class for filter implementations.
22 Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
23 <div id="cfg-Ext.ux.grid.filter.Filter-active"></div>/**
24 * @cfg {Boolean} active
25 * Indicates the initial status of the filter (defaults to false).
28 <div id="prop-Ext.ux.grid.filter.Filter-active"></div>/**
29 * True if this filter is active. Use setActive() to alter after configuration.
33 <div id="cfg-Ext.ux.grid.filter.Filter-dataIndex"></div>/**
34 * @cfg {String} dataIndex
35 * The {@link Ext.data.Store} dataIndex of the field this filter represents.
36 * The dataIndex does not actually have to exist in the store.
39 <div id="prop-Ext.ux.grid.filter.Filter-menu"></div>/**
40 * The filter configuration menu that will be installed into the filter submenu of a column menu.
45 <div id="cfg-Ext.ux.grid.filter.Filter-updateBuffer"></div>/**
46 * @cfg {Number} updateBuffer
47 * Number of milliseconds to wait after user interaction to fire an update. Only supported
48 * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
52 constructor : function (config) {
53 Ext.apply(this, config);
56 <div id="event-Ext.ux.grid.filter.Filter-activate"></div>/**
58 * Fires when an inactive filter becomes active
59 * @param {Ext.ux.grid.filter.Filter} this
62 <div id="event-Ext.ux.grid.filter.Filter-deactivate"></div>/**
64 * Fires when an active filter becomes inactive
65 * @param {Ext.ux.grid.filter.Filter} this
68 <div id="event-Ext.ux.grid.filter.Filter-serialize"></div>/**
70 * Fires after the serialization process. Use this to attach additional parameters to serialization
71 * data before it is encoded and sent to the server.
72 * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
73 * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
76 <div id="event-Ext.ux.grid.filter.Filter-update"></div>/**
78 * Fires when a filter configuration has changed
79 * @param {Ext.ux.grid.filter.Filter} this The filter object.
83 Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
85 this.menu = new Ext.menu.Menu();
87 if(config && config.value){
88 this.setValue(config.value);
89 this.setActive(config.active !== false, true);
94 <div id="method-Ext.ux.grid.filter.Filter-destroy"></div>/**
95 * Destroys this filter by purging any event listeners, and removing any menus.
101 this.purgeListeners();
104 <div id="prop-Ext.ux.grid.filter.Filter-init"></div>/**
105 * Template method to be implemented by all subclasses that is to
106 * initialize the filter and install required menu items.
107 * Defaults to Ext.emptyFn.
111 <div id="method-Ext.ux.grid.filter.Filter-getValue"></div>/**
112 * Template method to be implemented by all subclasses that is to
113 * get and return the value of the filter.
114 * Defaults to Ext.emptyFn.
115 * @return {Object} The 'serialized' form of this filter
116 * @methodOf Ext.ux.grid.filter.Filter
118 getValue : Ext.emptyFn,
120 <div id="method-Ext.ux.grid.filter.Filter-setValue"></div>/**
121 * Template method to be implemented by all subclasses that is to
122 * set the value of the filter and fire the 'update' event.
123 * Defaults to Ext.emptyFn.
124 * @param {Object} data The value to set the filter
125 * @methodOf Ext.ux.grid.filter.Filter
127 setValue : Ext.emptyFn,
129 <div id="method-Ext.ux.grid.filter.Filter-isActivatable"></div>/**
130 * Template method to be implemented by all subclasses that is to
131 * return <tt>true</tt> if the filter has enough configuration information to be activated.
132 * Defaults to <tt>return true</tt>.
135 isActivatable : function(){
139 <div id="prop-Ext.ux.grid.filter.Filter-getSerialArgs"></div>/**
140 * Template method to be implemented by all subclasses that is to
141 * get and return serialized filter data for transmission to the server.
142 * Defaults to Ext.emptyFn.
144 getSerialArgs : Ext.emptyFn,
146 <div id="method-Ext.ux.grid.filter.Filter-validateRecord"></div>/**
147 * Template method to be implemented by all subclasses that is to
148 * validates the provided Ext.data.Record against the filters configuration.
149 * Defaults to <tt>return true</tt>.
150 * @param {Ext.data.Record} record The record to validate
151 * @return {Boolean} true if the record is valid within the bounds
152 * of the filter, false otherwise.
154 validateRecord : function(){
158 <div id="method-Ext.ux.grid.filter.Filter-serialize"></div>/**
159 * Returns the serialized filter data for transmission to the server
160 * and fires the 'serialize' event.
161 * @return {Object/Array} An object or collection of objects containing
162 * key value pairs representing the current configuration of the filter.
163 * @methodOf Ext.ux.grid.filter.Filter
165 serialize : function(){
166 var args = this.getSerialArgs();
167 this.fireEvent('serialize', args, this);
172 fireUpdate : function(){
174 this.fireEvent('update', this);
176 this.setActive(this.isActivatable());
179 <div id="method-Ext.ux.grid.filter.Filter-setActive"></div>/**
180 * Sets the status of the filter and fires the appropriate events.
181 * @param {Boolean} active The new filter state.
182 * @param {Boolean} suppressEvent True to prevent events from being fired.
183 * @methodOf Ext.ux.grid.filter.Filter
185 setActive : function(active, suppressEvent){
186 if(this.active != active){
187 this.active = active;
188 if (suppressEvent !== true) {
189 this.fireEvent(active ? 'activate' : 'deactivate', this);