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"><div id="cls-Ext.ux.grid.filter.NumericFilter"></div>/**
\r
9 * @class Ext.ux.grid.filter.NumericFilter
\r
10 * @extends Ext.ux.grid.filter.Filter
\r
11 * Filters using an Ext.ux.menu.RangeMenu.
\r
12 * <p><b><u>Example Usage:</u></b></p>
\r
14 var filters = new Ext.ux.grid.GridFilters({
\r
23 Ext.ux.grid.filter.NumericFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
\r
25 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCls"></div>/**
\r
26 * @cfg {Object} fieldCls
\r
27 * The Class to use to construct each field item within this menu
\r
29 * fieldCls : Ext.form.NumberField
\r
32 fieldCls : Ext.form.NumberField,
\r
33 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fieldCfg"></div>/**
\r
34 * @cfg {Object} fieldCfg
\r
35 * The default configuration options for any field item unless superseded
\r
36 * by the <code>{@link #fields}</code> configuration.
\r
47 <div id="cfg-Ext.ux.grid.filter.NumericFilter-fields"></div>/**
\r
48 * @cfg {Object} fields
\r
49 * The field items may be configured individually
\r
50 * Defaults to <tt>undefined</tt>.
\r
54 gt: { // override fieldCfg options
\r
56 fieldCls: Ext.ux.form.CustomNumberField // to override default {@link #fieldCls}
\r
61 <div id="cfg-Ext.ux.grid.filter.NumericFilter-iconCls"></div>/**
\r
62 * @cfg {Object} iconCls
\r
63 * The iconCls to be applied to each comparator field item.
\r
66 gt : 'ux-rangemenu-gt',
\r
67 lt : 'ux-rangemenu-lt',
\r
68 eq : 'ux-rangemenu-eq'
\r
73 gt : 'ux-rangemenu-gt',
\r
74 lt : 'ux-rangemenu-lt',
\r
75 eq : 'ux-rangemenu-eq'
\r
78 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItemCfgs"></div>/**
\r
79 * @cfg {Object} menuItemCfgs
\r
80 * Default configuration options for each menu item
\r
83 emptyText: 'Enter Filter Text...',
\r
84 selectOnFocus: true,
\r
90 emptyText: 'Enter Filter Text...',
\r
91 selectOnFocus: true,
\r
95 <div id="cfg-Ext.ux.grid.filter.NumericFilter-menuItems"></div>/**
\r
96 * @cfg {Array} menuItems
\r
97 * The items to be shown in this menu. Items are added to the menu
\r
98 * according to their position within this array. Defaults to:<pre>
\r
99 * menuItems : ['lt','gt','-','eq']
\r
102 menuItems : ['lt', 'gt', '-', 'eq'],
\r
106 * Template method that is to initialize the filter and install required menu items.
\r
108 init : function (config) {
\r
109 // if a menu already existed, do clean up first
\r
111 this.menu.destroy();
\r
113 this.menu = new Ext.ux.menu.RangeMenu(Ext.apply(config, {
\r
114 // pass along filter configs to the menu
\r
115 fieldCfg : this.fieldCfg || {},
\r
116 fieldCls : this.fieldCls,
\r
117 fields : this.fields || {},
\r
118 iconCls: this.iconCls,
\r
119 menuItemCfgs: this.menuItemCfgs,
\r
120 menuItems: this.menuItems,
\r
121 updateBuffer: this.updateBuffer
\r
123 // relay the event fired by the menu
\r
124 this.menu.on('update', this.fireUpdate, this);
\r
129 * Template method that is to get and return the value of the filter.
\r
130 * @return {String} The value of this filter
\r
132 getValue : function () {
\r
133 return this.menu.getValue();
\r
138 * Template method that is to set the value of the filter.
\r
139 * @param {Object} value The value to set the filter
\r
141 setValue : function (value) {
\r
142 this.menu.setValue(value);
\r
147 * Template method that is to return <tt>true</tt> if the filter
\r
148 * has enough configuration information to be activated.
\r
149 * @return {Boolean}
\r
151 isActivatable : function () {
\r
152 var values = this.getValue();
\r
153 for (key in values) {
\r
154 if (values[key] !== undefined) {
\r
163 * Template method that is to get and return serialized filter data for
\r
164 * transmission to the server.
\r
165 * @return {Object/Array} An object or collection of objects containing
\r
166 * key value pairs representing the current configuration of the filter.
\r
168 getSerialArgs : function () {
\r
171 values = this.menu.getValue();
\r
172 for (key in values) {
\r
182 <div id="method-Ext.ux.grid.filter.NumericFilter-validateRecord"></div>/**
\r
183 * Template method that is to validate the provided Ext.data.Record
\r
184 * against the filters configuration.
\r
185 * @param {Ext.data.Record} record The record to validate
\r
186 * @return {Boolean} true if the record is valid within the bounds
\r
187 * of the filter, false otherwise.
\r
189 validateRecord : function (record) {
\r
190 var val = record.get(this.dataIndex),
\r
191 values = this.getValue();
\r
192 if (values.eq !== undefined && val != values.eq) {
\r
195 if (values.lt !== undefined && val >= values.lt) {
\r
198 if (values.gt !== undefined && val <= values.gt) {
\r