3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">Ext.namespace('Ext.ux.grid.filter');
\r
10 <div id="cls-Ext.ux.grid.filter.Filter"></div>/**
\r
11 * @class Ext.ux.grid.filter.Filter
\r
12 * @extends Ext.util.Observable
\r
13 * Abstract base class for filter implementations.
\r
15 Ext.ux.grid.filter.Filter = Ext.extend(Ext.util.Observable, {
\r
16 <div id="cfg-Ext.ux.grid.filter.Filter-active"></div>/**
\r
17 * @cfg {Boolean} active
\r
18 * Indicates the initial status of the filter (defaults to false).
\r
21 <div id="prop-Ext.ux.grid.filter.Filter-active"></div>/**
\r
22 * True if this filter is active. Use setActive() to alter after configuration.
\r
26 <div id="cfg-Ext.ux.grid.filter.Filter-dataIndex"></div>/**
\r
27 * @cfg {String} dataIndex
\r
28 * The {@link Ext.data.Store} dataIndex of the field this filter represents.
\r
29 * The dataIndex does not actually have to exist in the store.
\r
32 <div id="prop-Ext.ux.grid.filter.Filter-menu"></div>/**
\r
33 * The filter configuration menu that will be installed into the filter submenu of a column menu.
\r
34 * @type Ext.menu.Menu
\r
38 <div id="cfg-Ext.ux.grid.filter.Filter-updateBuffer"></div>/**
\r
39 * @cfg {Number} updateBuffer
\r
40 * Number of milliseconds to wait after user interaction to fire an update. Only supported
\r
41 * by filters: 'list', 'numeric', and 'string'. Defaults to 500.
\r
45 constructor : function (config) {
\r
46 Ext.apply(this, config);
\r
49 <div id="event-Ext.ux.grid.filter.Filter-activate"></div>/**
\r
51 * Fires when an inactive filter becomes active
\r
52 * @param {Ext.ux.grid.filter.Filter} this
\r
55 <div id="event-Ext.ux.grid.filter.Filter-deactivate"></div>/**
\r
57 * Fires when an active filter becomes inactive
\r
58 * @param {Ext.ux.grid.filter.Filter} this
\r
61 <div id="event-Ext.ux.grid.filter.Filter-serialize"></div>/**
\r
63 * Fires after the serialization process. Use this to attach additional parameters to serialization
\r
64 * data before it is encoded and sent to the server.
\r
65 * @param {Array/Object} data A map or collection of maps representing the current filter configuration.
\r
66 * @param {Ext.ux.grid.filter.Filter} filter The filter being serialized.
\r
69 <div id="event-Ext.ux.grid.filter.Filter-update"></div>/**
\r
71 * Fires when a filter configuration has changed
\r
72 * @param {Ext.ux.grid.filter.Filter} this The filter object.
\r
76 Ext.ux.grid.filter.Filter.superclass.constructor.call(this);
\r
78 this.menu = new Ext.menu.Menu();
\r
80 if(config && config.value){
\r
81 this.setValue(config.value);
\r
82 this.setActive(config.active !== false, true);
\r
83 delete config.value;
\r
87 <div id="method-Ext.ux.grid.filter.Filter-destroy"></div>/**
\r
88 * Destroys this filter by purging any event listeners, and removing any menus.
\r
90 destroy : function(){
\r
92 this.menu.destroy();
\r
94 this.purgeListeners();
\r
97 <div id="prop-Ext.ux.grid.filter.Filter-init"></div>/**
\r
98 * Template method to be implemented by all subclasses that is to
\r
99 * initialize the filter and install required menu items.
\r
100 * Defaults to Ext.emptyFn.
\r
102 init : Ext.emptyFn,
\r
104 <div id="method-Ext.ux.grid.filter.Filter-getValue"></div>/**
\r
105 * Template method to be implemented by all subclasses that is to
\r
106 * get and return the value of the filter.
\r
107 * Defaults to Ext.emptyFn.
\r
108 * @return {Object} The 'serialized' form of this filter
\r
109 * @methodOf Ext.ux.grid.filter.Filter
\r
111 getValue : Ext.emptyFn,
\r
113 <div id="method-Ext.ux.grid.filter.Filter-setValue"></div>/**
\r
114 * Template method to be implemented by all subclasses that is to
\r
115 * set the value of the filter and fire the 'update' event.
\r
116 * Defaults to Ext.emptyFn.
\r
117 * @param {Object} data The value to set the filter
\r
118 * @methodOf Ext.ux.grid.filter.Filter
\r
120 setValue : Ext.emptyFn,
\r
122 <div id="method-Ext.ux.grid.filter.Filter-isActivatable"></div>/**
\r
123 * Template method to be implemented by all subclasses that is to
\r
124 * return <tt>true</tt> if the filter has enough configuration information to be activated.
\r
125 * Defaults to <tt>return true</tt>.
\r
126 * @return {Boolean}
\r
128 isActivatable : function(){
\r
132 <div id="prop-Ext.ux.grid.filter.Filter-getSerialArgs"></div>/**
\r
133 * Template method to be implemented by all subclasses that is to
\r
134 * get and return serialized filter data for transmission to the server.
\r
135 * Defaults to Ext.emptyFn.
\r
137 getSerialArgs : Ext.emptyFn,
\r
139 <div id="method-Ext.ux.grid.filter.Filter-validateRecord"></div>/**
\r
140 * Template method to be implemented by all subclasses that is to
\r
141 * validates the provided Ext.data.Record against the filters configuration.
\r
142 * Defaults to <tt>return true</tt>.
\r
143 * @param {Ext.data.Record} record The record to validate
\r
144 * @return {Boolean} true if the record is valid within the bounds
\r
145 * of the filter, false otherwise.
\r
147 validateRecord : function(){
\r
151 <div id="method-Ext.ux.grid.filter.Filter-serialize"></div>/**
\r
152 * Returns the serialized filter data for transmission to the server
\r
153 * and fires the 'serialize' event.
\r
154 * @return {Object/Array} An object or collection of objects containing
\r
155 * key value pairs representing the current configuration of the filter.
\r
156 * @methodOf Ext.ux.grid.filter.Filter
\r
158 serialize : function(){
\r
159 var args = this.getSerialArgs();
\r
160 this.fireEvent('serialize', args, this);
\r
165 fireUpdate : function(){
\r
167 this.fireEvent('update', this);
\r
169 this.setActive(this.isActivatable());
\r
172 <div id="method-Ext.ux.grid.filter.Filter-setActive"></div>/**
\r
173 * Sets the status of the filter and fires the appropriate events.
\r
174 * @param {Boolean} active The new filter state.
\r
175 * @param {Boolean} suppressEvent True to prevent events from being fired.
\r
176 * @methodOf Ext.ux.grid.filter.Filter
\r
178 setActive : function(active, suppressEvent){
\r
179 if(this.active != active){
\r
180 this.active = active;
\r
181 if (suppressEvent !== true) {
\r
182 this.fireEvent(active ? 'activate' : 'deactivate', this);
\r