3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.ux.grid.filter.NumericFilter
9 * @extends Ext.ux.grid.filter.Filter
10 * Filters using an Ext.ux.menu.RangeMenu.
11 * <p><b><u>Example Usage:</u></b></p>
13 var filters = new Ext.ux.grid.GridFilters({
22 Ext.ux.grid.filter.NumericFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
25 * @cfg {Object} fieldCls
26 * The Class to use to construct each field item within this menu
28 * fieldCls : Ext.form.NumberField
31 fieldCls : Ext.form.NumberField,
33 * @cfg {Object} fieldCfg
34 * The default configuration options for any field item unless superseded
35 * by the <code>{@link #fields}</code> configuration.
47 * @cfg {Object} fields
48 * The field items may be configured individually
49 * Defaults to <tt>undefined</tt>.
53 gt: { // override fieldCfg options
55 fieldCls: Ext.ux.form.CustomNumberField // to override default {@link #fieldCls}
61 * @cfg {Object} iconCls
62 * The iconCls to be applied to each comparator field item.
65 gt : 'ux-rangemenu-gt',
66 lt : 'ux-rangemenu-lt',
67 eq : 'ux-rangemenu-eq'
72 gt : 'ux-rangemenu-gt',
73 lt : 'ux-rangemenu-lt',
74 eq : 'ux-rangemenu-eq'
78 * @cfg {Object} menuItemCfgs
79 * Default configuration options for each menu item
82 emptyText: 'Enter Filter Text...',
89 emptyText: 'Enter Filter Text...',
95 * @cfg {Array} menuItems
96 * The items to be shown in this menu. Items are added to the menu
97 * according to their position within this array. Defaults to:<pre>
98 * menuItems : ['lt','gt','-','eq']
101 menuItems : ['lt', 'gt', '-', 'eq'],
105 * Template method that is to initialize the filter and install required menu items.
107 init : function (config) {
108 // if a menu already existed, do clean up first
112 this.menu = new Ext.ux.menu.RangeMenu(Ext.apply(config, {
113 // pass along filter configs to the menu
114 fieldCfg : this.fieldCfg || {},
115 fieldCls : this.fieldCls,
116 fields : this.fields || {},
117 iconCls: this.iconCls,
118 menuItemCfgs: this.menuItemCfgs,
119 menuItems: this.menuItems,
120 updateBuffer: this.updateBuffer
122 // relay the event fired by the menu
123 this.menu.on('update', this.fireUpdate, this);
128 * Template method that is to get and return the value of the filter.
129 * @return {String} The value of this filter
131 getValue : function () {
132 return this.menu.getValue();
137 * Template method that is to set the value of the filter.
138 * @param {Object} value The value to set the filter
140 setValue : function (value) {
141 this.menu.setValue(value);
146 * Template method that is to return <tt>true</tt> if the filter
147 * has enough configuration information to be activated.
150 isActivatable : function () {
151 var values = this.getValue();
152 for (key in values) {
153 if (values[key] !== undefined) {
162 * Template method that is to get and return serialized filter data for
163 * transmission to the server.
164 * @return {Object/Array} An object or collection of objects containing
165 * key value pairs representing the current configuration of the filter.
167 getSerialArgs : function () {
170 values = this.menu.getValue();
171 for (key in values) {
182 * Template method that is to validate the provided Ext.data.Record
183 * against the filters configuration.
184 * @param {Ext.data.Record} record The record to validate
185 * @return {Boolean} true if the record is valid within the bounds
186 * of the filter, false otherwise.
188 validateRecord : function (record) {
189 var val = record.get(this.dataIndex),
190 values = this.getValue();
191 if (values.eq !== undefined && val != values.eq) {
194 if (values.lt !== undefined && val >= values.lt) {
197 if (values.gt !== undefined && val <= values.gt) {