3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
10 * @class Ext.ux.menu.RangeMenu
11 * @extends Ext.menu.Menu
12 * Custom implementation of Ext.menu.Menu that has preconfigured
13 * items for gt, lt, eq.
14 * <p><b><u>Example Usage:</u></b></p>
19 Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
21 constructor : function (config) {
23 Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
28 * Fires when a filter configuration has changed
29 * @param {Ext.ux.grid.filter.Filter} this The filter object.
34 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
36 var i, len, item, cfg, Cls;
38 for (i = 0, len = this.menuItems.length; i < len; i++) {
39 item = this.menuItems[i];
43 itemId: 'range-' + item,
44 enableKeyEvents: true,
45 iconCls: this.iconCls[item] || 'no-icon',
48 keyup: this.onInputKeyUp
54 Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
55 // configurable defaults
58 Cls = cfg.fieldCls || this.fieldCls;
59 item = this.fields[item] = new Cls(cfg);
67 * called by this.updateTask
69 fireUpdate : function () {
70 this.fireEvent('update', this);
74 * Get and return the value of the filter.
75 * @return {String} The value of this filter
77 getValue : function () {
78 var result = {}, key, field;
79 for (key in this.fields) {
80 field = this.fields[key];
81 if (field.isValid() && String(field.getValue()).length > 0) {
82 result[key] = field.getValue();
89 * Set the value of this menu and fires the 'update' event.
90 * @param {Object} data The data to assign to this menu
92 setValue : function (data) {
94 for (key in this.fields) {
95 this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
97 this.fireEvent('update', this);
102 * Handler method called when there is a keyup event on an input
105 onInputKeyUp : function (field, e) {
107 if (k == e.RETURN && field.isValid()) {
113 if (field == this.fields.eq) {
114 if (this.fields.gt) {
115 this.fields.gt.setValue(null);
117 if (this.fields.lt) {
118 this.fields.lt.setValue(null);
122 this.fields.eq.setValue(null);
126 this.updateTask.delay(this.updateBuffer);