Filter2.html
7.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<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>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js"><span id='Ext-ux-grid-filter-Filter'>/**
</span> * @class Ext.ux.grid.filter.Filter
* @extends Ext.util.Observable
* Abstract base class for filter implementations.
*/
Ext.define('Ext.ux.grid.filter.Filter', {
extend: 'Ext.util.Observable',
<span id='Ext-ux-grid-filter-Filter-cfg-active'> /**
</span> * @cfg {Boolean} active
* Indicates the initial status of the filter (defaults to false).
*/
active : false,
<span id='Ext-ux-grid-filter-Filter-property-active'> /**
</span> * True if this filter is active. Use setActive() to alter after configuration.
* @type Boolean
* @property active
*/
<span id='Ext-ux-grid-filter-Filter-cfg-dataIndex'> /**
</span> * @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,
<span id='Ext-ux-grid-filter-Filter-property-menu'> /**
</span> * The filter configuration menu that will be installed into the filter submenu of a column menu.
* @type Ext.menu.Menu
* @property
*/
menu : null,
<span id='Ext-ux-grid-filter-Filter-cfg-updateBuffer'> /**
</span> * @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(
<span id='Ext-ux-grid-filter-Filter-event-activate'> /**
</span> * @event activate
* Fires when an inactive filter becomes active
* @param {Ext.ux.grid.filter.Filter} this
*/
'activate',
<span id='Ext-ux-grid-filter-Filter-event-deactivate'> /**
</span> * @event deactivate
* Fires when an active filter becomes inactive
* @param {Ext.ux.grid.filter.Filter} this
*/
'deactivate',
<span id='Ext-ux-grid-filter-Filter-event-serialize'> /**
</span> * @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',
<span id='Ext-ux-grid-filter-Filter-event-update'> /**
</span> * @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 = this.createMenu(config);
this.init(config);
if(config && config.value){
this.setValue(config.value);
this.setActive(config.active !== false, true);
delete config.value;
}
},
<span id='Ext-ux-grid-filter-Filter-method-destroy'> /**
</span> * Destroys this filter by purging any event listeners, and removing any menus.
*/
destroy : function(){
if (this.menu){
this.menu.destroy();
}
this.clearListeners();
},
<span id='Ext-ux-grid-filter-Filter-method-init'> /**
</span> * 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,
<span id='Ext-ux-grid-filter-Filter-method-createMenu'> /**
</span> * @private @override
* Creates the Menu for this filter.
* @param {Object} config Filter configuration
* @return {Ext.menu.Menu}
*/
createMenu: function(config) {
return Ext.create('Ext.menu.Menu', config);
},
<span id='Ext-ux-grid-filter-Filter-method-getValue'> /**
</span> * 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,
<span id='Ext-ux-grid-filter-Filter-method-setValue'> /**
</span> * 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,
<span id='Ext-ux-grid-filter-Filter-method-isActivatable'> /**
</span> * 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;
},
<span id='Ext-ux-grid-filter-Filter-method-getSerialArgs'> /**
</span> * 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,
<span id='Ext-ux-grid-filter-Filter-method-validateRecord'> /**
</span> * 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;
},
<span id='Ext-ux-grid-filter-Filter-method-serialize'> /**
</span> * 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;
},
<span id='Ext-ux-grid-filter-Filter-method-fireUpdate'> /** @private */
</span> fireUpdate : function(){
if (this.active) {
this.fireEvent('update', this);
}
this.setActive(this.isActivatable());
},
<span id='Ext-ux-grid-filter-Filter-method-setActive'> /**
</span> * 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>