3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.ux.grid.filter.NumericFilter
17 * @extends Ext.ux.grid.filter.Filter
18 * Filters using an Ext.ux.grid.menu.RangeMenu.
19 * <p><b><u>Example Usage:</u></b></p>
21 var filters = Ext.create('Ext.ux.grid.GridFilters', {
29 * <p>Any of the configuration options for {@link Ext.ux.grid.menu.RangeMenu} can also be specified as
30 * configurations to NumericFilter, and will be copied over to the internal menu instance automatically.</p>
32 Ext.define('Ext.ux.grid.filter.NumericFilter', {
33 extend: 'Ext.ux.grid.filter.Filter',
34 alias: 'gridfilter.numeric',
35 uses: ['Ext.form.field.Number'],
39 * Creates the Menu for this filter.
40 * @param {Object} config Filter configuration
41 * @return {Ext.menu.Menu}
43 createMenu: function(config) {
46 menu = Ext.create('Ext.ux.grid.menu.RangeMenu', config);
47 menu.on('update', me.fireUpdate, me);
53 * Template method that is to get and return the value of the filter.
54 * @return {String} The value of this filter
56 getValue : function () {
57 return this.menu.getValue();
62 * Template method that is to set the value of the filter.
63 * @param {Object} value The value to set the filter
65 setValue : function (value) {
66 this.menu.setValue(value);
71 * Template method that is to return <tt>true</tt> if the filter
72 * has enough configuration information to be activated.
75 isActivatable : function () {
76 var values = this.getValue(),
79 if (values[key] !== undefined) {
88 * Template method that is to get and return serialized filter data for
89 * transmission to the server.
90 * @return {Object/Array} An object or collection of objects containing
91 * key value pairs representing the current configuration of the filter.
93 getSerialArgs : function () {
96 values = this.menu.getValue();
108 * Template method that is to validate the provided Ext.data.Record
109 * against the filters configuration.
110 * @param {Ext.data.Record} record The record to validate
111 * @return {Boolean} true if the record is valid within the bounds
112 * of the filter, false otherwise.
114 validateRecord : function (record) {
115 var val = record.get(this.dataIndex),
116 values = this.getValue(),
117 isNumber = Ext.isNumber;
118 if (isNumber(values.eq) && val != values.eq) {
121 if (isNumber(values.lt) && val >= values.lt) {
124 if (isNumber(values.gt) && val <= values.gt) {