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 Ext.ns('Ext.ux.menu');
17 <div id="cls-Ext.ux.menu.RangeMenu"></div>/**
18 * @class Ext.ux.menu.RangeMenu
19 * @extends Ext.menu.Menu
20 * Custom implementation of Ext.menu.Menu that has preconfigured
21 * items for gt, lt, eq.
22 * <p><b><u>Example Usage:</u></b></p>
27 Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
29 constructor : function (config) {
31 Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
34 <div id="event-Ext.ux.menu.RangeMenu-update"></div>/**
36 * Fires when a filter configuration has changed
37 * @param {Ext.ux.grid.filter.Filter} this The filter object.
42 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
44 var i, len, item, cfg, Cls;
46 for (i = 0, len = this.menuItems.length; i < len; i++) {
47 item = this.menuItems[i];
51 itemId: 'range-' + item,
52 enableKeyEvents: true,
53 iconCls: this.iconCls[item] || 'no-icon',
56 keyup: this.onInputKeyUp
62 Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
63 // configurable defaults
66 Cls = cfg.fieldCls || this.fieldCls;
67 item = this.fields[item] = new Cls(cfg);
75 * called by this.updateTask
77 fireUpdate : function () {
78 this.fireEvent('update', this);
81 <div id="method-Ext.ux.menu.RangeMenu-getValue"></div>/**
82 * Get and return the value of the filter.
83 * @return {String} The value of this filter
85 getValue : function () {
86 var result = {}, key, field;
87 for (key in this.fields) {
88 field = this.fields[key];
89 if (field.isValid() && String(field.getValue()).length > 0) {
90 result[key] = field.getValue();
96 <div id="method-Ext.ux.menu.RangeMenu-setValue"></div>/**
97 * Set the value of this menu and fires the 'update' event.
98 * @param {Object} data The data to assign to this menu
100 setValue : function (data) {
102 for (key in this.fields) {
103 this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
105 this.fireEvent('update', this);
110 * Handler method called when there is a keyup event on an input
113 onInputKeyUp : function (field, e) {
115 if (k == e.RETURN && field.isValid()) {
121 if (field == this.fields.eq) {
122 if (this.fields.gt) {
123 this.fields.gt.setValue(null);
125 if (this.fields.lt) {
126 this.fields.lt.setValue(null);
130 this.fields.eq.setValue(null);
134 this.updateTask.delay(this.updateBuffer);