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 <div id="cls-Ext.ux.grid.filter.NumericFilter"></div>/**
16 * @class Ext.ux.grid.filter.NumericFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * Filters using an Ext.ux.menu.RangeMenu.
19 * <p><b><u>Example Usage:</u></b></p>
21 var filters = new Ext.ux.grid.GridFilters({
30 Ext.ux.grid.filter.NumericFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
32 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCls"></div>/**
33 * @cfg {Object} fieldCls
34 * The Class to use to construct each field item within this menu
36 * fieldCls : Ext.form.NumberField
39 fieldCls : Ext.form.NumberField,
40 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCfg"></div>/**
41 * @cfg {Object} fieldCfg
42 * The default configuration options for any field item unless superseded
43 * by the <code>{@link #fields}</code> configuration.
54 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fields"></div>/**
55 * @cfg {Object} fields
56 * The field items may be configured individually
57 * Defaults to <tt>undefined</tt>.
61 gt: { // override fieldCfg options
63 fieldCls: Ext.ux.form.CustomNumberField // to override default {@link #fieldCls}
68 <div id="cfg-Ext.ux.grid.filter.NumericFilter-iconCls"></div>/**
69 * @cfg {Object} iconCls
70 * The iconCls to be applied to each comparator field item.
73 gt : 'ux-rangemenu-gt',
74 lt : 'ux-rangemenu-lt',
75 eq : 'ux-rangemenu-eq'
80 gt : 'ux-rangemenu-gt',
81 lt : 'ux-rangemenu-lt',
82 eq : 'ux-rangemenu-eq'
85 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItemCfgs"></div>/**
86 * @cfg {Object} menuItemCfgs
87 * Default configuration options for each menu item
90 emptyText: 'Enter Filter Text...',
97 emptyText: 'Enter Filter Text...',
102 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItems"></div>/**
103 * @cfg {Array} menuItems
104 * The items to be shown in this menu. Items are added to the menu
105 * according to their position within this array. Defaults to:<pre>
106 * menuItems : ['lt','gt','-','eq']
109 menuItems : ['lt', 'gt', '-', 'eq'],
113 * Template method that is to initialize the filter and install required menu items.
115 init : function (config) {
116 // if a menu already existed, do clean up first
120 this.menu = new Ext.ux.menu.RangeMenu(Ext.apply(config, {
121 // pass along filter configs to the menu
122 fieldCfg : this.fieldCfg || {},
123 fieldCls : this.fieldCls,
124 fields : this.fields || {},
125 iconCls: this.iconCls,
126 menuItemCfgs: this.menuItemCfgs,
127 menuItems: this.menuItems,
128 updateBuffer: this.updateBuffer
130 // relay the event fired by the menu
131 this.menu.on('update', this.fireUpdate, this);
136 * Template method that is to get and return the value of the filter.
137 * @return {String} The value of this filter
139 getValue : function () {
140 return this.menu.getValue();
145 * Template method that is to set the value of the filter.
146 * @param {Object} value The value to set the filter
148 setValue : function (value) {
149 this.menu.setValue(value);
154 * Template method that is to return <tt>true</tt> if the filter
155 * has enough configuration information to be activated.
158 isActivatable : function () {
159 var values = this.getValue();
160 for (key in values) {
161 if (values[key] !== undefined) {
170 * Template method that is to get and return serialized filter data for
171 * transmission to the server.
172 * @return {Object/Array} An object or collection of objects containing
173 * key value pairs representing the current configuration of the filter.
175 getSerialArgs : function () {
178 values = this.menu.getValue();
179 for (key in values) {
189 <div id="method-Ext.ux.grid.filter.NumericFilter-validateRecord"></div>/**
190 * Template method that is to validate the provided Ext.data.Record
191 * against the filters configuration.
192 * @param {Ext.data.Record} record The record to validate
193 * @return {Boolean} true if the record is valid within the bounds
194 * of the filter, false otherwise.
196 validateRecord : function (record) {
197 var val = record.get(this.dataIndex),
198 values = this.getValue();
199 if (values.eq !== undefined && val != values.eq) {
202 if (values.lt !== undefined && val >= values.lt) {
205 if (values.gt !== undefined && val <= values.gt) {