<html>
<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.0.3
- * Copyright(c) 2006-2009 Ext JS, LLC
+ * Ext JS Library 3.2.1
+ * Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
-<div id="cls-Ext.form.ComboBox"></div>/**\r
- * @class Ext.form.ComboBox\r
- * @extends Ext.form.TriggerField\r
- * <p>A combobox control with support for autocomplete, remote-loading, paging and many other features.</p>\r
- * <p>A ComboBox works in a similar manner to a traditional HTML <select> field. The difference is\r
- * that to submit the {@link #valueField}, you must specify a {@link #hiddenName} to create a hidden input\r
- * field to hold the value of the valueField. The <i>{@link #displayField}</i> is shown in the text field\r
- * which is named according to the {@link #name}.</p>\r
- * <p><b><u>Events</u></b></p>\r
- * <p>To do something when something in ComboBox is selected, configure the select event:<pre><code>\r
-var cb = new Ext.form.ComboBox({\r
- // all of your config options\r
- listeners:{\r
- scope: yourScope,\r
- 'select': yourFunction\r
- }\r
-});\r
-\r
-// Alternatively, you can assign events after the object is created:\r
-var cb = new Ext.form.ComboBox(yourOptions);\r
-cb.on('select', yourFunction, yourScope);\r
- * </code></pre></p>\r
- *\r
- * <p><b><u>ComboBox in Grid</u></b></p>\r
- * <p>If using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a {@link Ext.grid.Column#renderer renderer}\r
- * will be needed to show the displayField when the editor is not active. Set up the renderer manually, or implement\r
- * a reusable render, for example:<pre><code>\r
-// create reusable renderer\r
-Ext.util.Format.comboRenderer = function(combo){\r
- return function(value){\r
- var record = combo.findRecord(combo.{@link #valueField}, value);\r
- return record ? record.get(combo.{@link #displayField}) : combo.{@link #valueNotFoundText};\r
- }\r
-}\r
-\r
-// create the combo instance\r
-var combo = new Ext.form.ComboBox({\r
- {@link #typeAhead}: true,\r
- {@link #triggerAction}: 'all',\r
- {@link #lazyRender}:true,\r
- {@link #mode}: 'local',\r
- {@link #store}: new Ext.data.ArrayStore({\r
- id: 0,\r
- fields: [\r
- 'myId',\r
- 'displayText'\r
- ],\r
- data: [[1, 'item1'], [2, 'item2']]\r
- }),\r
- {@link #valueField}: 'myId',\r
- {@link #displayField}: 'displayText'\r
-});\r
-\r
-// snippet of column model used within grid\r
-var cm = new Ext.grid.ColumnModel([{\r
- ...\r
- },{\r
- header: "Some Header",\r
- dataIndex: 'whatever',\r
- width: 130,\r
- editor: combo, // specify reference to combo instance\r
- renderer: Ext.util.Format.comboRenderer(combo) // pass combo instance to reusable renderer\r
- },\r
- ...\r
-]);\r
- * </code></pre></p>\r
- *\r
- * <p><b><u>Filtering</u></b></p>\r
- * <p>A ComboBox {@link #doQuery uses filtering itself}, for information about filtering the ComboBox\r
- * store manually see <tt>{@link #lastQuery}</tt>.</p>\r
- * @constructor\r
- * Create a new ComboBox.\r
- * @param {Object} config Configuration options\r
- * @xtype combo\r
- */\r
-Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {\r
- <div id="cfg-Ext.form.ComboBox-transform"></div>/**\r
- * @cfg {Mixed} transform The id, DOM node or element of an existing HTML SELECT to convert to a ComboBox.\r
- * Note that if you specify this and the combo is going to be in an {@link Ext.form.BasicForm} or\r
- * {@link Ext.form.FormPanel}, you must also set <tt>{@link #lazyRender} = true</tt>.\r
- */\r
- <div id="cfg-Ext.form.ComboBox-lazyRender"></div>/**\r
- * @cfg {Boolean} lazyRender <tt>true</tt> to prevent the ComboBox from rendering until requested\r
- * (should always be used when rendering into an {@link Ext.Editor} (e.g. {@link Ext.grid.EditorGridPanel Grids}),\r
- * defaults to <tt>false</tt>).\r
- */\r
- <div id="cfg-Ext.form.ComboBox-autoCreate"></div>/**\r
- * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or <tt>true</tt> for a default\r
- * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.\r
- * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>\r
- * <pre><code>{tag: "input", type: "text", size: "24", autocomplete: "off"}</code></pre>\r
- */\r
- <div id="cfg-Ext.form.ComboBox-store"></div>/**\r
- * @cfg {Ext.data.Store/Array} store The data source to which this combo is bound (defaults to <tt>undefined</tt>).\r
- * Acceptable values for this property are:\r
- * <div class="mdetail-params"><ul>\r
- * <li><b>any {@link Ext.data.Store Store} subclass</b></li>\r
- * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally,\r
- * automatically generating {@link Ext.data.Field#name field names} to work with all data components.\r
- * <div class="mdetail-params"><ul>\r
- * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">\r
- * A 1-dimensional array will automatically be expanded (each array item will be used for both the combo\r
- * {@link #valueField} and {@link #displayField})</div></li>\r
- * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">\r
- * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo\r
- * {@link #valueField}, while the value at index 1 is assumed to be the combo {@link #displayField}.\r
- * </div></li></ul></div></li></ul></div>\r
- * <p>See also <tt>{@link #mode}</tt>.</p>\r
- */\r
- <div id="cfg-Ext.form.ComboBox-title"></div>/**\r
- * @cfg {String} title If supplied, a header element is created containing this text and added into the top of\r
- * the dropdown list (defaults to undefined, with no header element)\r
- */\r
-\r
- // private\r
- defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},\r
- <div id="cfg-Ext.form.ComboBox-listWidth"></div>/**\r
- * @cfg {Number} listWidth The width (used as a parameter to {@link Ext.Element#setWidth}) of the dropdown\r
- * list (defaults to the width of the ComboBox field). See also <tt>{@link #minListWidth}\r
- */\r
- <div id="cfg-Ext.form.ComboBox-displayField"></div>/**\r
- * @cfg {String} displayField The underlying {@link Ext.data.Field#name data field name} to bind to this\r
- * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field1'</tt> if\r
- * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on\r
- * the store configuration}).\r
- * <p>See also <tt>{@link #valueField}</tt>.</p>\r
- * <p><b>Note</b>: if using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a\r
- * {@link Ext.grid.Column#renderer renderer} will be needed to show the displayField when the editor is not\r
- * active.</p>\r
- */\r
- <div id="cfg-Ext.form.ComboBox-valueField"></div>/**\r
- * @cfg {String} valueField The underlying {@link Ext.data.Field#name data value name} to bind to this\r
- * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field2'</tt> if\r
- * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on\r
- * the store configuration}).\r
- * <p><b>Note</b>: use of a <tt>valueField</tt> requires the user to make a selection in order for a value to be\r
- * mapped. See also <tt>{@link #hiddenName}</tt>, <tt>{@link #hiddenValue}</tt>, and <tt>{@link #displayField}</tt>.</p>\r
- */\r
- <div id="cfg-Ext.form.ComboBox-hiddenName"></div>/**\r
- * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the\r
- * field's data value (defaults to the underlying DOM element's name). Required for the combo's value to automatically\r
- * post during a form submission. See also {@link #valueField}.\r
- * <p><b>Note</b>: the hidden field's id will also default to this name if {@link #hiddenId} is not specified.\r
- * The ComboBox {@link Ext.Component#id id} and the <tt>{@link #hiddenId}</tt> <b>should be different</b>, since\r
- * no two DOM nodes should share the same id. So, if the ComboBox <tt>{@link Ext.form.Field#name name}</tt> and\r
- * <tt>hiddenName</tt> are the same, you should specify a unique <tt>{@link #hiddenId}</tt>.</p>\r
- */\r
- <div id="cfg-Ext.form.ComboBox-hiddenId"></div>/**\r
- * @cfg {String} hiddenId If <tt>{@link #hiddenName}</tt> is specified, <tt>hiddenId</tt> can also be provided\r
- * to give the hidden field a unique id (defaults to the <tt>{@link #hiddenName}</tt>). The <tt>hiddenId</tt>\r
- * and combo {@link Ext.Component#id id} should be different, since no two DOM\r
- * nodes should share the same id.\r
- */\r
- <div id="cfg-Ext.form.ComboBox-hiddenValue"></div>/**\r
- * @cfg {String} hiddenValue Sets the initial value of the hidden field if {@link #hiddenName} is\r
- * specified to contain the selected {@link #valueField}, from the Store. Defaults to the configured\r
- * <tt>{@link Ext.form.Field#value value}</tt>.\r
- */\r
- <div id="cfg-Ext.form.ComboBox-listClass"></div>/**\r
- * @cfg {String} listClass The CSS class to add to the predefined <tt>'x-combo-list'</tt> class\r
- * applied the dropdown list element (defaults to '').\r
- */\r
- listClass : '',\r
- <div id="cfg-Ext.form.ComboBox-selectedClass"></div>/**\r
- * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list\r
- * (defaults to <tt>'x-combo-selected'</tt>)\r
- */\r
- selectedClass : 'x-combo-selected',\r
- <div id="cfg-Ext.form.ComboBox-listEmptyText"></div>/**\r
- * @cfg {String} listEmptyText The empty text to display in the data view if no items are found.\r
- * (defaults to '')\r
- */\r
- listEmptyText: '',\r
- <div id="cfg-Ext.form.ComboBox-triggerClass"></div>/**\r
- * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always\r
- * get the class <tt>'x-form-trigger'</tt> and <tt>triggerClass</tt> will be <b>appended</b> if specified\r
- * (defaults to <tt>'x-form-arrow-trigger'</tt> which displays a downward arrow icon).\r
- */\r
- triggerClass : 'x-form-arrow-trigger',\r
- <div id="cfg-Ext.form.ComboBox-shadow"></div>/**\r
- * @cfg {Boolean/String} shadow <tt>true</tt> or <tt>"sides"</tt> for the default effect, <tt>"frame"</tt> for\r
- * 4-way shadow, and <tt>"drop"</tt> for bottom-right\r
- */\r
- shadow : 'sides',\r
- <div id="cfg-Ext.form.ComboBox-listAlign"></div>/**\r
- * @cfg {String} listAlign A valid anchor position value. See <tt>{@link Ext.Element#alignTo}</tt> for details\r
- * on supported anchor positions (defaults to <tt>'tl-bl?'</tt>)\r
- */\r
- listAlign : 'tl-bl?',\r
- <div id="cfg-Ext.form.ComboBox-maxHeight"></div>/**\r
- * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown\r
- * (defaults to <tt>300</tt>)\r
- */\r
- maxHeight : 300,\r
- <div id="cfg-Ext.form.ComboBox-minHeight"></div>/**\r
- * @cfg {Number} minHeight The minimum height in pixels of the dropdown list when the list is constrained by its\r
- * distance to the viewport edges (defaults to <tt>90</tt>)\r
- */\r
- minHeight : 90,\r
- <div id="cfg-Ext.form.ComboBox-triggerAction"></div>/**\r
- * @cfg {String} triggerAction The action to execute when the trigger is clicked.\r
- * <div class="mdetail-params"><ul>\r
- * <li><b><tt>'query'</tt></b> : <b>Default</b>\r
- * <p class="sub-desc">{@link #doQuery run the query} using the {@link Ext.form.Field#getRawValue raw value}.</p></li>\r
- * <li><b><tt>'all'</tt></b> :\r
- * <p class="sub-desc">{@link #doQuery run the query} specified by the <tt>{@link #allQuery}</tt> config option</p></li>\r
- * </ul></div>\r
- * <p>See also <code>{@link #queryParam}</code>.</p>\r
- */\r
- triggerAction : 'query',\r
- <div id="cfg-Ext.form.ComboBox-minChars"></div>/**\r
- * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and\r
- * {@link #typeAhead} activate (defaults to <tt>4</tt> if <tt>{@link #mode} = 'remote'</tt> or <tt>0</tt> if\r
- * <tt>{@link #mode} = 'local'</tt>, does not apply if\r
- * <tt>{@link Ext.form.TriggerField#editable editable} = false</tt>).\r
- */\r
- minChars : 4,\r
- <div id="cfg-Ext.form.ComboBox-typeAhead"></div>/**\r
- * @cfg {Boolean} typeAhead <tt>true</tt> to populate and autoselect the remainder of the text being\r
- * typed after a configurable delay ({@link #typeAheadDelay}) if it matches a known value (defaults\r
- * to <tt>false</tt>)\r
- */\r
- typeAhead : false,\r
- <div id="cfg-Ext.form.ComboBox-queryDelay"></div>/**\r
- * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and\r
- * sending the query to filter the dropdown list (defaults to <tt>500</tt> if <tt>{@link #mode} = 'remote'</tt>\r
- * or <tt>10</tt> if <tt>{@link #mode} = 'local'</tt>)\r
- */\r
- queryDelay : 500,\r
- <div id="cfg-Ext.form.ComboBox-pageSize"></div>/**\r
- * @cfg {Number} pageSize If greater than <tt>0</tt>, a {@link Ext.PagingToolbar} is displayed in the\r
- * footer of the dropdown list and the {@link #doQuery filter queries} will execute with page start and\r
- * {@link Ext.PagingToolbar#pageSize limit} parameters. Only applies when <tt>{@link #mode} = 'remote'</tt>\r
- * (defaults to <tt>0</tt>).\r
- */\r
- pageSize : 0,\r
- <div id="cfg-Ext.form.ComboBox-selectOnFocus"></div>/**\r
- * @cfg {Boolean} selectOnFocus <tt>true</tt> to select any existing text in the field immediately on focus.\r
- * Only applies when <tt>{@link Ext.form.TriggerField#editable editable} = true</tt> (defaults to\r
- * <tt>false</tt>).\r
- */\r
- selectOnFocus : false,\r
- <div id="cfg-Ext.form.ComboBox-queryParam"></div>/**\r
- * @cfg {String} queryParam Name of the query ({@link Ext.data.Store#baseParam baseParam} name for the store)\r
- * as it will be passed on the querystring (defaults to <tt>'query'</tt>)\r
- */\r
- queryParam : 'query',\r
- <div id="cfg-Ext.form.ComboBox-loadingText"></div>/**\r
- * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies\r
- * when <tt>{@link #mode} = 'remote'</tt> (defaults to <tt>'Loading...'</tt>)\r
- */\r
- loadingText : 'Loading...',\r
- <div id="cfg-Ext.form.ComboBox-resizable"></div>/**\r
- * @cfg {Boolean} resizable <tt>true</tt> to add a resize handle to the bottom of the dropdown list\r
- * (creates an {@link Ext.Resizable} with 'se' {@link Ext.Resizable#pinned pinned} handles).\r
- * Defaults to <tt>false</tt>.\r
- */\r
- resizable : false,\r
- <div id="cfg-Ext.form.ComboBox-handleHeight"></div>/**\r
- * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if\r
- * <tt>{@link #resizable} = true</tt> (defaults to <tt>8</tt>)\r
- */\r
- handleHeight : 8,\r
- <div id="cfg-Ext.form.ComboBox-allQuery"></div>/**\r
- * @cfg {String} allQuery The text query to send to the server to return all records for the list\r
- * with no filtering (defaults to '')\r
- */\r
- allQuery: '',\r
- <div id="cfg-Ext.form.ComboBox-mode"></div>/**\r
- * @cfg {String} mode Acceptable values are:\r
- * <div class="mdetail-params"><ul>\r
- * <li><b><tt>'remote'</tt></b> : <b>Default</b>\r
- * <p class="sub-desc">Automatically loads the <tt>{@link #store}</tt> the <b>first</b> time the trigger\r
- * is clicked. If you do not want the store to be automatically loaded the first time the trigger is\r
- * clicked, set to <tt>'local'</tt> and manually load the store. To force a requery of the store\r
- * <b>every</b> time the trigger is clicked see <tt>{@link #lastQuery}</tt>.</p></li>\r
- * <li><b><tt>'local'</tt></b> :\r
- * <p class="sub-desc">ComboBox loads local data</p>\r
- * <pre><code>\r
-var combo = new Ext.form.ComboBox({\r
- renderTo: document.body,\r
- mode: 'local',\r
- store: new Ext.data.ArrayStore({\r
- id: 0,\r
- fields: [\r
- 'myId', // numeric value is the key\r
- 'displayText'\r
- ],\r
- data: [[1, 'item1'], [2, 'item2']] // data is local\r
- }),\r
- valueField: 'myId',\r
- displayField: 'displayText',\r
- triggerAction: 'all'\r
-});\r
- * </code></pre></li>\r
- * </ul></div>\r
- */\r
- mode: 'remote',\r
- <div id="cfg-Ext.form.ComboBox-minListWidth"></div>/**\r
- * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to <tt>70</tt>, will\r
- * be ignored if <tt>{@link #listWidth}</tt> has a higher value)\r
- */\r
- minListWidth : 70,\r
- <div id="cfg-Ext.form.ComboBox-forceSelection"></div>/**\r
- * @cfg {Boolean} forceSelection <tt>true</tt> to restrict the selected value to one of the values in the list,\r
- * <tt>false</tt> to allow the user to set arbitrary text into the field (defaults to <tt>false</tt>)\r
- */\r
- forceSelection : false,\r
- <div id="cfg-Ext.form.ComboBox-typeAheadDelay"></div>/**\r
- * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed\r
- * if <tt>{@link #typeAhead} = true</tt> (defaults to <tt>250</tt>)\r
- */\r
- typeAheadDelay : 250,\r
- <div id="cfg-Ext.form.ComboBox-valueNotFoundText"></div>/**\r
- * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in\r
- * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined). If this\r
- * default text is used, it means there is no value set and no validation will occur on this field.\r
- */\r
-\r
- <div id="cfg-Ext.form.ComboBox-lazyInit"></div>/**\r
- * @cfg {Boolean} lazyInit <tt>true</tt> to not initialize the list for this combo until the field is focused\r
- * (defaults to <tt>true</tt>)\r
- */\r
- lazyInit : true,\r
-\r
- <div id="prop-Ext.form.ComboBox-lastQuery"></div>/**\r
- * The value of the match string used to filter the store. Delete this property to force a requery.\r
- * Example use:\r
- * <pre><code>\r
-var combo = new Ext.form.ComboBox({\r
- ...\r
- mode: 'remote',\r
- ...\r
- listeners: {\r
- // delete the previous query in the beforequery event or set\r
- // combo.lastQuery = null (this will reload the store the next time it expands)\r
- beforequery: function(qe){\r
- delete qe.combo.lastQuery;\r
- }\r
- }\r
-});\r
- * </code></pre>\r
- * To make sure the filter in the store is not cleared the first time the ComboBox trigger is used\r
- * configure the combo with <tt>lastQuery=''</tt>. Example use:\r
- * <pre><code>\r
-var combo = new Ext.form.ComboBox({\r
- ...\r
- mode: 'local',\r
- triggerAction: 'all',\r
- lastQuery: ''\r
-});\r
- * </code></pre>\r
- * @property lastQuery\r
- * @type String\r
- */\r
-\r
- // private\r
- initComponent : function(){\r
- Ext.form.ComboBox.superclass.initComponent.call(this);\r
- this.addEvents(\r
- <div id="event-Ext.form.ComboBox-expand"></div>/**\r
- * @event expand\r
- * Fires when the dropdown list is expanded\r
- * @param {Ext.form.ComboBox} combo This combo box\r
- */\r
- 'expand',\r
- <div id="event-Ext.form.ComboBox-collapse"></div>/**\r
- * @event collapse\r
- * Fires when the dropdown list is collapsed\r
- * @param {Ext.form.ComboBox} combo This combo box\r
- */\r
- 'collapse',\r
- <div id="event-Ext.form.ComboBox-beforeselect"></div>/**\r
- * @event beforeselect\r
- * Fires before a list item is selected. Return false to cancel the selection.\r
- * @param {Ext.form.ComboBox} combo This combo box\r
- * @param {Ext.data.Record} record The data record returned from the underlying store\r
- * @param {Number} index The index of the selected item in the dropdown list\r
- */\r
- 'beforeselect',\r
- <div id="event-Ext.form.ComboBox-select"></div>/**\r
- * @event select\r
- * Fires when a list item is selected\r
- * @param {Ext.form.ComboBox} combo This combo box\r
- * @param {Ext.data.Record} record The data record returned from the underlying store\r
- * @param {Number} index The index of the selected item in the dropdown list\r
- */\r
- 'select',\r
- <div id="event-Ext.form.ComboBox-beforequery"></div>/**\r
- * @event beforequery\r
- * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's\r
- * cancel property to true.\r
- * @param {Object} queryEvent An object that has these properties:<ul>\r
- * <li><code>combo</code> : Ext.form.ComboBox <div class="sub-desc">This combo box</div></li>\r
- * <li><code>query</code> : String <div class="sub-desc">The query</div></li>\r
- * <li><code>forceAll</code> : Boolean <div class="sub-desc">True to force "all" query</div></li>\r
- * <li><code>cancel</code> : Boolean <div class="sub-desc">Set to true to cancel the query</div></li>\r
- * </ul>\r
- */\r
- 'beforequery'\r
- );\r
- if(this.transform){\r
- var s = Ext.getDom(this.transform);\r
- if(!this.hiddenName){\r
- this.hiddenName = s.name;\r
- }\r
- if(!this.store){\r
- this.mode = 'local';\r
- var d = [], opts = s.options;\r
- for(var i = 0, len = opts.length;i < len; i++){\r
- var o = opts[i],\r
- value = (o.hasAttribute ? o.hasAttribute('value') : o.getAttributeNode('value').specified) ? o.value : o.text;\r
- if(o.selected && Ext.isEmpty(this.value, true)) {\r
- this.value = value;\r
- }\r
- d.push([value, o.text]);\r
- }\r
- this.store = new Ext.data.ArrayStore({\r
- 'id': 0,\r
- fields: ['value', 'text'],\r
- data : d,\r
- autoDestroy: true\r
- });\r
- this.valueField = 'value';\r
- this.displayField = 'text';\r
- }\r
- s.name = Ext.id(); // wipe out the name in case somewhere else they have a reference\r
- if(!this.lazyRender){\r
- this.target = true;\r
- this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);\r
- this.render(this.el.parentNode, s);\r
- Ext.removeNode(s); // remove it\r
- }else{\r
- Ext.removeNode(s); // remove it\r
- }\r
- }\r
- //auto-configure store from local array data\r
- else if(this.store){\r
- this.store = Ext.StoreMgr.lookup(this.store);\r
- if(this.store.autoCreated){\r
- this.displayField = this.valueField = 'field1';\r
- if(!this.store.expandData){\r
- this.displayField = 'field2';\r
- }\r
- this.mode = 'local';\r
- }\r
- }\r
-\r
- this.selectedIndex = -1;\r
- if(this.mode == 'local'){\r
- if(!Ext.isDefined(this.initialConfig.queryDelay)){\r
- this.queryDelay = 10;\r
- }\r
- if(!Ext.isDefined(this.initialConfig.minChars)){\r
- this.minChars = 0;\r
- }\r
- }\r
- },\r
-\r
- // private\r
- onRender : function(ct, position){\r
- Ext.form.ComboBox.superclass.onRender.call(this, ct, position);\r
- if(this.hiddenName){\r
- this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,\r
- id: (this.hiddenId||this.hiddenName)}, 'before', true);\r
-\r
- // prevent input submission\r
- this.el.dom.removeAttribute('name');\r
- }\r
- if(Ext.isGecko){\r
- this.el.dom.setAttribute('autocomplete', 'off');\r
- }\r
-\r
- if(!this.lazyInit){\r
- this.initList();\r
- }else{\r
- this.on('focus', this.initList, this, {single: true});\r
- }\r
- },\r
-\r
- // private\r
- initValue : function(){\r
- Ext.form.ComboBox.superclass.initValue.call(this);\r
- if(this.hiddenField){\r
- this.hiddenField.value =\r
- Ext.isDefined(this.hiddenValue) ? this.hiddenValue :\r
- Ext.isDefined(this.value) ? this.value : '';\r
- }\r
- },\r
-\r
- // private\r
- initList : function(){\r
- if(!this.list){\r
- var cls = 'x-combo-list';\r
-\r
- this.list = new Ext.Layer({\r
- parentEl: this.getListParent(),\r
- shadow: this.shadow,\r
- cls: [cls, this.listClass].join(' '),\r
- constrain:false\r
- });\r
-\r
- var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);\r
- this.list.setSize(lw, 0);\r
- this.list.swallowEvent('mousewheel');\r
- this.assetHeight = 0;\r
- if(this.syncFont !== false){\r
- this.list.setStyle('font-size', this.el.getStyle('font-size'));\r
- }\r
- if(this.title){\r
- this.header = this.list.createChild({cls:cls+'-hd', html: this.title});\r
- this.assetHeight += this.header.getHeight();\r
- }\r
-\r
- this.innerList = this.list.createChild({cls:cls+'-inner'});\r
- this.mon(this.innerList, 'mouseover', this.onViewOver, this);\r
- this.mon(this.innerList, 'mousemove', this.onViewMove, this);\r
- this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));\r
-\r
- if(this.pageSize){\r
- this.footer = this.list.createChild({cls:cls+'-ft'});\r
- this.pageTb = new Ext.PagingToolbar({\r
- store: this.store,\r
- pageSize: this.pageSize,\r
- renderTo:this.footer\r
- });\r
- this.assetHeight += this.footer.getHeight();\r
- }\r
-\r
- if(!this.tpl){\r
- <div id="cfg-Ext.form.ComboBox-tpl"></div>/**\r
- * @cfg {String/Ext.XTemplate} tpl <p>The template string, or {@link Ext.XTemplate} instance to\r
- * use to display each item in the dropdown list. The dropdown list is displayed in a\r
- * DataView. See {@link #view}.</p>\r
- * <p>The default template string is:</p><pre><code>\r
- '<tpl for="."><div class="x-combo-list-item">{' + this.displayField + '}</div></tpl>'\r
- * </code></pre>\r
- * <p>Override the default value to create custom UI layouts for items in the list.\r
- * For example:</p><pre><code>\r
- '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>'\r
- * </code></pre>\r
- * <p>The template <b>must</b> contain one or more substitution parameters using field\r
- * names from the Combo's</b> {@link #store Store}. In the example above an\r
- * <pre>ext:qtip</pre> attribute is added to display other fields from the Store.</p>\r
- * <p>To preserve the default visual look of list items, add the CSS class name\r
- * <pre>x-combo-list-item</pre> to the template's container element.</p>\r
- * <p>Also see {@link #itemSelector} for additional details.</p>\r
- */\r
- this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';\r
- <div id="cfg-Ext.form.ComboBox-itemSelector"></div>/**\r
- * @cfg {String} itemSelector\r
- * <p>A simple CSS selector (e.g. div.some-class or span:first-child) that will be\r
- * used to determine what nodes the {@link #view Ext.DataView} which handles the dropdown\r
- * display will be working with.</p>\r
- * <p><b>Note</b>: this setting is <b>required</b> if a custom XTemplate has been\r
- * specified in {@link #tpl} which assigns a class other than <pre>'x-combo-list-item'</pre>\r
- * to dropdown list items</b>\r
- */\r
- }\r
-\r
- <div id="prop-Ext.form.ComboBox-view"></div>/**\r
- * The {@link Ext.DataView DataView} used to display the ComboBox's options.\r
- * @type Ext.DataView\r
- */\r
- this.view = new Ext.DataView({\r
- applyTo: this.innerList,\r
- tpl: this.tpl,\r
- singleSelect: true,\r
- selectedClass: this.selectedClass,\r
- itemSelector: this.itemSelector || '.' + cls + '-item',\r
- emptyText: this.listEmptyText\r
- });\r
-\r
- this.mon(this.view, 'click', this.onViewClick, this);\r
-\r
- this.bindStore(this.store, true);\r
-\r
- if(this.resizable){\r
- this.resizer = new Ext.Resizable(this.list, {\r
- pinned:true, handles:'se'\r
- });\r
- this.mon(this.resizer, 'resize', function(r, w, h){\r
- this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;\r
- this.listWidth = w;\r
- this.innerList.setWidth(w - this.list.getFrameWidth('lr'));\r
- this.restrictHeight();\r
- }, this);\r
-\r
- this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');\r
- }\r
- }\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-getListParent"></div>/**\r
- * <p>Returns the element used to house this ComboBox's pop-up list. Defaults to the document body.</p>\r
- * A custom implementation may be provided as a configuration option if the floating list needs to be rendered\r
- * to a different Element. An example might be rendering the list inside a Menu so that clicking\r
- * the list does not hide the Menu:<pre><code>\r
-var store = new Ext.data.ArrayStore({\r
- autoDestroy: true,\r
- fields: ['initials', 'fullname'],\r
- data : [\r
- ['FF', 'Fred Flintstone'],\r
- ['BR', 'Barney Rubble']\r
- ]\r
-});\r
-\r
-var combo = new Ext.form.ComboBox({\r
- store: store,\r
- displayField: 'fullname',\r
- emptyText: 'Select a name...',\r
- forceSelection: true,\r
- getListParent: function() {\r
- return this.el.up('.x-menu');\r
- },\r
- iconCls: 'no-icon', //use iconCls if placing within menu to shift to right side of menu\r
- mode: 'local',\r
- selectOnFocus: true,\r
- triggerAction: 'all',\r
- typeAhead: true,\r
- width: 135\r
-});\r
-\r
-var menu = new Ext.menu.Menu({\r
- id: 'mainMenu',\r
- items: [\r
- combo // A Field in a Menu\r
- ]\r
-});\r
-</code></pre>\r
- */\r
- getListParent : function() {\r
- return document.body;\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-getStore"></div>/**\r
- * Returns the store associated with this combo.\r
- * @return {Ext.data.Store} The store\r
- */\r
- getStore : function(){\r
- return this.store;\r
- },\r
-\r
- // private\r
- bindStore : function(store, initial){\r
- if(this.store && !initial){\r
- if(this.store !== store && this.store.autoDestroy){\r
- this.store.destroy();\r
- }else{\r
- this.store.un('beforeload', this.onBeforeLoad, this);\r
- this.store.un('load', this.onLoad, this);\r
- this.store.un('exception', this.collapse, this);\r
- }\r
- if(!store){\r
- this.store = null;\r
- if(this.view){\r
- this.view.bindStore(null);\r
- }\r
- if(this.pageTb){\r
- this.pageTb.bindStore(null);\r
- }\r
- }\r
- }\r
- if(store){\r
- if(!initial) {\r
- this.lastQuery = null;\r
- if(this.pageTb) {\r
- this.pageTb.bindStore(store);\r
- }\r
- }\r
-\r
- this.store = Ext.StoreMgr.lookup(store);\r
- this.store.on({\r
- scope: this,\r
- beforeload: this.onBeforeLoad,\r
- load: this.onLoad,\r
- exception: this.collapse\r
- });\r
-\r
- if(this.view){\r
- this.view.bindStore(store);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- initEvents : function(){\r
- Ext.form.ComboBox.superclass.initEvents.call(this);\r
-\r
- this.keyNav = new Ext.KeyNav(this.el, {\r
- "up" : function(e){\r
- this.inKeyMode = true;\r
- this.selectPrev();\r
- },\r
-\r
- "down" : function(e){\r
- if(!this.isExpanded()){\r
- this.onTriggerClick();\r
- }else{\r
- this.inKeyMode = true;\r
- this.selectNext();\r
- }\r
- },\r
-\r
- "enter" : function(e){\r
- this.onViewClick();\r
- },\r
-\r
- "esc" : function(e){\r
- this.collapse();\r
- },\r
-\r
- "tab" : function(e){\r
- this.onViewClick(false);\r
- return true;\r
- },\r
-\r
- scope : this,\r
-\r
- doRelay : function(e, h, hname){\r
- if(hname == 'down' || this.scope.isExpanded()){\r
- // this MUST be called before ComboBox#fireKey()\r
- var relay = Ext.KeyNav.prototype.doRelay.apply(this, arguments);\r
- if(!Ext.isIE && Ext.EventManager.useKeydown){\r
- // call Combo#fireKey() for browsers which use keydown event (except IE)\r
- this.scope.fireKey(e);\r
- }\r
- return relay;\r
- }\r
- return true;\r
- },\r
-\r
- forceKeyDown : true,\r
- defaultEventAction: 'stopEvent'\r
- });\r
- this.queryDelay = Math.max(this.queryDelay || 10,\r
- this.mode == 'local' ? 10 : 250);\r
- this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);\r
- if(this.typeAhead){\r
- this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);\r
- }\r
- if(this.editable !== false && !this.enableKeyEvents){\r
- this.mon(this.el, 'keyup', this.onKeyUp, this);\r
- }\r
- },\r
-\r
- // private\r
- onDestroy : function(){\r
- if (this.dqTask){\r
- this.dqTask.cancel();\r
- this.dqTask = null;\r
- }\r
- this.bindStore(null);\r
- Ext.destroy(\r
- this.resizer,\r
- this.view,\r
- this.pageTb,\r
- this.list\r
- );\r
- Ext.form.ComboBox.superclass.onDestroy.call(this);\r
- },\r
-\r
- // private\r
- fireKey : function(e){\r
- if (!this.isExpanded()) {\r
- Ext.form.ComboBox.superclass.fireKey.call(this, e);\r
- }\r
- },\r
-\r
- // private\r
- onResize : function(w, h){\r
- Ext.form.ComboBox.superclass.onResize.apply(this, arguments);\r
- if(this.isVisible() && this.list){\r
- this.doResize(w);\r
- }else{\r
- this.bufferSize = w;\r
- }\r
- },\r
- \r
- doResize: function(w){\r
- if(!Ext.isDefined(this.listWidth)){\r
- var lw = Math.max(w, this.minListWidth);\r
- this.list.setWidth(lw);\r
- this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));\r
- } \r
- },\r
-\r
- // private\r
- onEnable : function(){\r
- Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);\r
- if(this.hiddenField){\r
- this.hiddenField.disabled = false;\r
- }\r
- },\r
-\r
- // private\r
- onDisable : function(){\r
- Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);\r
- if(this.hiddenField){\r
- this.hiddenField.disabled = true;\r
- }\r
- },\r
-\r
- // private\r
- onBeforeLoad : function(){\r
- if(!this.hasFocus){\r
- return;\r
- }\r
- this.innerList.update(this.loadingText ?\r
- '<div class="loading-indicator">'+this.loadingText+'</div>' : '');\r
- this.restrictHeight();\r
- this.selectedIndex = -1;\r
- },\r
-\r
- // private\r
- onLoad : function(){\r
- if(!this.hasFocus){\r
- return;\r
- }\r
- if(this.store.getCount() > 0 || this.listEmptyText){\r
- this.expand();\r
- this.restrictHeight();\r
- if(this.lastQuery == this.allQuery){\r
- if(this.editable){\r
- this.el.dom.select();\r
- }\r
- if(!this.selectByValue(this.value, true)){\r
- this.select(0, true);\r
- }\r
- }else{\r
- this.selectNext();\r
- if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){\r
- this.taTask.delay(this.typeAheadDelay);\r
- }\r
- }\r
- }else{\r
- this.onEmptyResults();\r
- }\r
- //this.el.focus();\r
- },\r
-\r
- // private\r
- onTypeAhead : function(){\r
- if(this.store.getCount() > 0){\r
- var r = this.store.getAt(0);\r
- var newValue = r.data[this.displayField];\r
- var len = newValue.length;\r
- var selStart = this.getRawValue().length;\r
- if(selStart != len){\r
- this.setRawValue(newValue);\r
- this.selectText(selStart, newValue.length);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- onSelect : function(record, index){\r
- if(this.fireEvent('beforeselect', this, record, index) !== false){\r
- this.setValue(record.data[this.valueField || this.displayField]);\r
- this.collapse();\r
- this.fireEvent('select', this, record, index);\r
- }\r
- },\r
-\r
- // inherit docs\r
- getName: function(){\r
- var hf = this.hiddenField;\r
- return hf && hf.name ? hf.name : this.hiddenName || Ext.form.ComboBox.superclass.getName.call(this);\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-getValue"></div>/**\r
- * Returns the currently selected field value or empty string if no value is set.\r
- * @return {String} value The selected value\r
- */\r
- getValue : function(){\r
- if(this.valueField){\r
- return Ext.isDefined(this.value) ? this.value : '';\r
- }else{\r
- return Ext.form.ComboBox.superclass.getValue.call(this);\r
- }\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-clearValue"></div>/**\r
- * Clears any text/value currently set in the field\r
- */\r
- clearValue : function(){\r
- if(this.hiddenField){\r
- this.hiddenField.value = '';\r
- }\r
- this.setRawValue('');\r
- this.lastSelectionText = '';\r
- this.applyEmptyText();\r
- this.value = '';\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-setValue"></div>/**\r
- * Sets the specified value into the field. If the value finds a match, the corresponding record text\r
- * will be displayed in the field. If the value does not match the data value of an existing item,\r
- * and the valueNotFoundText config option is defined, it will be displayed as the default field text.\r
- * Otherwise the field will be blank (although the value will still be set).\r
- * @param {String} value The value to match\r
- * @return {Ext.form.Field} this\r
- */\r
- setValue : function(v){\r
- var text = v;\r
- if(this.valueField){\r
- var r = this.findRecord(this.valueField, v);\r
- if(r){\r
- text = r.data[this.displayField];\r
- }else if(Ext.isDefined(this.valueNotFoundText)){\r
- text = this.valueNotFoundText;\r
- }\r
- }\r
- this.lastSelectionText = text;\r
- if(this.hiddenField){\r
- this.hiddenField.value = v;\r
- }\r
- Ext.form.ComboBox.superclass.setValue.call(this, text);\r
- this.value = v;\r
- return this;\r
- },\r
-\r
- // private\r
- findRecord : function(prop, value){\r
- var record;\r
- if(this.store.getCount() > 0){\r
- this.store.each(function(r){\r
- if(r.data[prop] == value){\r
- record = r;\r
- return false;\r
- }\r
- });\r
- }\r
- return record;\r
- },\r
-\r
- // private\r
- onViewMove : function(e, t){\r
- this.inKeyMode = false;\r
- },\r
-\r
- // private\r
- onViewOver : function(e, t){\r
- if(this.inKeyMode){ // prevent key nav and mouse over conflicts\r
- return;\r
- }\r
- var item = this.view.findItemFromChild(t);\r
- if(item){\r
- var index = this.view.indexOf(item);\r
- this.select(index, false);\r
- }\r
- },\r
-\r
- // private\r
- onViewClick : function(doFocus){\r
- var index = this.view.getSelectedIndexes()[0],\r
- s = this.store,\r
- r = s.getAt(index);\r
- if(r){\r
- this.onSelect(r, index);\r
- }else if(s.getCount() === 0){\r
- this.onEmptyResults();\r
- }\r
- if(doFocus !== false){\r
- this.el.focus();\r
- }\r
- },\r
-\r
- // private\r
- restrictHeight : function(){\r
- this.innerList.dom.style.height = '';\r
- var inner = this.innerList.dom,\r
- pad = this.list.getFrameWidth('tb') + (this.resizable ? this.handleHeight : 0) + this.assetHeight,\r
- h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight),\r
- ha = this.getPosition()[1]-Ext.getBody().getScroll().top,\r
- hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height,\r
- space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;\r
- \r
- h = Math.min(h, space, this.maxHeight);\r
-\r
- this.innerList.setHeight(h);\r
- this.list.beginUpdate();\r
- this.list.setHeight(h+pad);\r
- this.list.alignTo(this.wrap, this.listAlign);\r
- this.list.endUpdate();\r
- },\r
-\r
- // private\r
- onEmptyResults : function(){\r
- this.collapse();\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-isExpanded"></div>/**\r
- * Returns true if the dropdown list is expanded, else false.\r
- */\r
- isExpanded : function(){\r
- return this.list && this.list.isVisible();\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-selectByValue"></div>/**\r
- * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.\r
- * The store must be loaded and the list expanded for this function to work, otherwise use setValue.\r
- * @param {String} value The data value of the item to select\r
- * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the\r
- * selected item if it is not currently in view (defaults to true)\r
- * @return {Boolean} True if the value matched an item in the list, else false\r
- */\r
- selectByValue : function(v, scrollIntoView){\r
- if(!Ext.isEmpty(v, true)){\r
- var r = this.findRecord(this.valueField || this.displayField, v);\r
- if(r){\r
- this.select(this.store.indexOf(r), scrollIntoView);\r
- return true;\r
- }\r
- }\r
- return false;\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-select"></div>/**\r
- * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.\r
- * The store must be loaded and the list expanded for this function to work, otherwise use setValue.\r
- * @param {Number} index The zero-based index of the list item to select\r
- * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the\r
- * selected item if it is not currently in view (defaults to true)\r
- */\r
- select : function(index, scrollIntoView){\r
- this.selectedIndex = index;\r
- this.view.select(index);\r
- if(scrollIntoView !== false){\r
- var el = this.view.getNode(index);\r
- if(el){\r
- this.innerList.scrollChildIntoView(el, false);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- selectNext : function(){\r
- var ct = this.store.getCount();\r
- if(ct > 0){\r
- if(this.selectedIndex == -1){\r
- this.select(0);\r
- }else if(this.selectedIndex < ct-1){\r
- this.select(this.selectedIndex+1);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- selectPrev : function(){\r
- var ct = this.store.getCount();\r
- if(ct > 0){\r
- if(this.selectedIndex == -1){\r
- this.select(0);\r
- }else if(this.selectedIndex !== 0){\r
- this.select(this.selectedIndex-1);\r
- }\r
- }\r
- },\r
-\r
- // private\r
- onKeyUp : function(e){\r
- var k = e.getKey();\r
- if(this.editable !== false && (k == e.BACKSPACE || !e.isSpecialKey())){\r
- this.lastKey = k;\r
- this.dqTask.delay(this.queryDelay);\r
- }\r
- Ext.form.ComboBox.superclass.onKeyUp.call(this, e);\r
- },\r
-\r
- // private\r
- validateBlur : function(){\r
- return !this.list || !this.list.isVisible();\r
- },\r
-\r
- // private\r
- initQuery : function(){\r
- this.doQuery(this.getRawValue());\r
- },\r
-\r
- // private\r
- beforeBlur : function(){\r
- var val = this.getRawValue(),\r
- rec = this.findRecord(this.displayField, val);\r
- if(!rec && this.forceSelection){\r
- if(val.length > 0 && val != this.emptyText){\r
- this.el.dom.value = Ext.isDefined(this.lastSelectionText) ? this.lastSelectionText : '';\r
- this.applyEmptyText();\r
- }else{\r
- this.clearValue();\r
- }\r
- }else{\r
- if(rec){\r
- val = rec.get(this.valueField || this.displayField);\r
- }\r
- this.setValue(val);\r
- }\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-doQuery"></div>/**\r
- * Execute a query to filter the dropdown list. Fires the {@link #beforequery} event prior to performing the\r
- * query allowing the query action to be canceled if needed.\r
- * @param {String} query The SQL query to execute\r
- * @param {Boolean} forceAll <tt>true</tt> to force the query to execute even if there are currently fewer\r
- * characters in the field than the minimum specified by the <tt>{@link #minChars}</tt> config option. It\r
- * also clears any filter previously saved in the current store (defaults to <tt>false</tt>)\r
- */\r
- doQuery : function(q, forceAll){\r
- q = Ext.isEmpty(q) ? '' : q;\r
- var qe = {\r
- query: q,\r
- forceAll: forceAll,\r
- combo: this,\r
- cancel:false\r
- };\r
- if(this.fireEvent('beforequery', qe)===false || qe.cancel){\r
- return false;\r
- }\r
- q = qe.query;\r
- forceAll = qe.forceAll;\r
- if(forceAll === true || (q.length >= this.minChars)){\r
- if(this.lastQuery !== q){\r
- this.lastQuery = q;\r
- if(this.mode == 'local'){\r
- this.selectedIndex = -1;\r
- if(forceAll){\r
- this.store.clearFilter();\r
- }else{\r
- this.store.filter(this.displayField, q);\r
- }\r
- this.onLoad();\r
- }else{\r
- this.store.baseParams[this.queryParam] = q;\r
- this.store.load({\r
- params: this.getParams(q)\r
- });\r
- this.expand();\r
- }\r
- }else{\r
- this.selectedIndex = -1;\r
- this.onLoad();\r
- }\r
- }\r
- },\r
-\r
- // private\r
- getParams : function(q){\r
- var p = {};\r
- //p[this.queryParam] = q;\r
- if(this.pageSize){\r
- p.start = 0;\r
- p.limit = this.pageSize;\r
- }\r
- return p;\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-collapse"></div>/**\r
- * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.\r
- */\r
- collapse : function(){\r
- if(!this.isExpanded()){\r
- return;\r
- }\r
- this.list.hide();\r
- Ext.getDoc().un('mousewheel', this.collapseIf, this);\r
- Ext.getDoc().un('mousedown', this.collapseIf, this);\r
- this.fireEvent('collapse', this);\r
- },\r
-\r
- // private\r
- collapseIf : function(e){\r
- if(!e.within(this.wrap) && !e.within(this.list)){\r
- this.collapse();\r
- }\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-expand"></div>/**\r
- * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.\r
- */\r
- expand : function(){\r
- if(this.isExpanded() || !this.hasFocus){\r
- return;\r
- }\r
- if(this.bufferSize){\r
- this.doResize(this.bufferSize);\r
- delete this.bufferSize;\r
- }\r
- this.list.alignTo(this.wrap, this.listAlign);\r
- this.list.show();\r
- if(Ext.isGecko2){\r
- this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac\r
- }\r
- Ext.getDoc().on({\r
- scope: this,\r
- mousewheel: this.collapseIf,\r
- mousedown: this.collapseIf\r
- });\r
- this.fireEvent('expand', this);\r
- },\r
-\r
- <div id="method-Ext.form.ComboBox-onTriggerClick"></div>/**\r
- * @method onTriggerClick\r
- * @hide\r
- */\r
- // private\r
- // Implements the default empty TriggerField.onTriggerClick function\r
- onTriggerClick : function(){\r
- if(this.disabled){\r
- return;\r
- }\r
- if(this.isExpanded()){\r
- this.collapse();\r
- this.el.focus();\r
- }else {\r
- this.onFocus({});\r
- if(this.triggerAction == 'all') {\r
- this.doQuery(this.allQuery, true);\r
- } else {\r
- this.doQuery(this.getRawValue());\r
- }\r
- this.el.focus();\r
- }\r
- }\r
-\r
- <div id="method-Ext.form.ComboBox-autoSize"></div>/**\r
- * @hide\r
- * @method autoSize\r
- */\r
- <div id="cfg-Ext.form.ComboBox-grow"></div>/**\r
- * @cfg {Boolean} grow @hide\r
- */\r
- <div id="cfg-Ext.form.ComboBox-growMin"></div>/**\r
- * @cfg {Number} growMin @hide\r
- */\r
- <div id="cfg-Ext.form.ComboBox-growMax"></div>/**\r
- * @cfg {Number} growMax @hide\r
- */\r
-\r
-});\r
-Ext.reg('combo', Ext.form.ComboBox);</pre>
+<div id="cls-Ext.form.ComboBox"></div>/**
+ * @class Ext.form.ComboBox
+ * @extends Ext.form.TriggerField
+ * <p>A combobox control with support for autocomplete, remote-loading, paging and many other features.</p>
+ * <p>A ComboBox works in a similar manner to a traditional HTML <select> field. The difference is
+ * that to submit the {@link #valueField}, you must specify a {@link #hiddenName} to create a hidden input
+ * field to hold the value of the valueField. The <i>{@link #displayField}</i> is shown in the text field
+ * which is named according to the {@link #name}.</p>
+ * <p><b><u>Events</u></b></p>
+ * <p>To do something when something in ComboBox is selected, configure the select event:<pre><code>
+var cb = new Ext.form.ComboBox({
+ // all of your config options
+ listeners:{
+ scope: yourScope,
+ 'select': yourFunction
+ }
+});
+
+// Alternatively, you can assign events after the object is created:
+var cb = new Ext.form.ComboBox(yourOptions);
+cb.on('select', yourFunction, yourScope);
+ * </code></pre></p>
+ *
+ * <p><b><u>ComboBox in Grid</u></b></p>
+ * <p>If using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a {@link Ext.grid.Column#renderer renderer}
+ * will be needed to show the displayField when the editor is not active. Set up the renderer manually, or implement
+ * a reusable render, for example:<pre><code>
+// create reusable renderer
+Ext.util.Format.comboRenderer = function(combo){
+ return function(value){
+ var record = combo.findRecord(combo.{@link #valueField}, value);
+ return record ? record.get(combo.{@link #displayField}) : combo.{@link #valueNotFoundText};
+ }
+}
+
+// create the combo instance
+var combo = new Ext.form.ComboBox({
+ {@link #typeAhead}: true,
+ {@link #triggerAction}: 'all',
+ {@link #lazyRender}:true,
+ {@link #mode}: 'local',
+ {@link #store}: new Ext.data.ArrayStore({
+ id: 0,
+ fields: [
+ 'myId',
+ 'displayText'
+ ],
+ data: [[1, 'item1'], [2, 'item2']]
+ }),
+ {@link #valueField}: 'myId',
+ {@link #displayField}: 'displayText'
+});
+
+// snippet of column model used within grid
+var cm = new Ext.grid.ColumnModel([{
+ ...
+ },{
+ header: "Some Header",
+ dataIndex: 'whatever',
+ width: 130,
+ editor: combo, // specify reference to combo instance
+ renderer: Ext.util.Format.comboRenderer(combo) // pass combo instance to reusable renderer
+ },
+ ...
+]);
+ * </code></pre></p>
+ *
+ * <p><b><u>Filtering</u></b></p>
+ * <p>A ComboBox {@link #doQuery uses filtering itself}, for information about filtering the ComboBox
+ * store manually see <tt>{@link #lastQuery}</tt>.</p>
+ * @constructor
+ * Create a new ComboBox.
+ * @param {Object} config Configuration options
+ * @xtype combo
+ */
+Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {
+ <div id="cfg-Ext.form.ComboBox-transform"></div>/**
+ * @cfg {Mixed} transform The id, DOM node or element of an existing HTML SELECT to convert to a ComboBox.
+ * Note that if you specify this and the combo is going to be in an {@link Ext.form.BasicForm} or
+ * {@link Ext.form.FormPanel}, you must also set <tt>{@link #lazyRender} = true</tt>.
+ */
+ <div id="cfg-Ext.form.ComboBox-lazyRender"></div>/**
+ * @cfg {Boolean} lazyRender <tt>true</tt> to prevent the ComboBox from rendering until requested
+ * (should always be used when rendering into an {@link Ext.Editor} (e.g. {@link Ext.grid.EditorGridPanel Grids}),
+ * defaults to <tt>false</tt>).
+ */
+ <div id="cfg-Ext.form.ComboBox-autoCreate"></div>/**
+ * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or <tt>true</tt> for a default
+ * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
+ * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details. Defaults to:</p>
+ * <pre><code>{tag: "input", type: "text", size: "24", autocomplete: "off"}</code></pre>
+ */
+ <div id="cfg-Ext.form.ComboBox-store"></div>/**
+ * @cfg {Ext.data.Store/Array} store The data source to which this combo is bound (defaults to <tt>undefined</tt>).
+ * Acceptable values for this property are:
+ * <div class="mdetail-params"><ul>
+ * <li><b>any {@link Ext.data.Store Store} subclass</b></li>
+ * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally,
+ * automatically generating {@link Ext.data.Field#name field names} to work with all data components.
+ * <div class="mdetail-params"><ul>
+ * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">
+ * A 1-dimensional array will automatically be expanded (each array item will be used for both the combo
+ * {@link #valueField} and {@link #displayField})</div></li>
+ * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">
+ * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo
+ * {@link #valueField}, while the value at index 1 is assumed to be the combo {@link #displayField}.
+ * </div></li></ul></div></li></ul></div>
+ * <p>See also <tt>{@link #mode}</tt>.</p>
+ */
+ <div id="cfg-Ext.form.ComboBox-title"></div>/**
+ * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
+ * the dropdown list (defaults to undefined, with no header element)
+ */
+
+ // private
+ defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
+ <div id="cfg-Ext.form.ComboBox-listWidth"></div>/**
+ * @cfg {Number} listWidth The width (used as a parameter to {@link Ext.Element#setWidth}) of the dropdown
+ * list (defaults to the width of the ComboBox field). See also <tt>{@link #minListWidth}
+ */
+ <div id="cfg-Ext.form.ComboBox-displayField"></div>/**
+ * @cfg {String} displayField The underlying {@link Ext.data.Field#name data field name} to bind to this
+ * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field1'</tt> if
+ * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on
+ * the store configuration}).
+ * <p>See also <tt>{@link #valueField}</tt>.</p>
+ * <p><b>Note</b>: if using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a
+ * {@link Ext.grid.Column#renderer renderer} will be needed to show the displayField when the editor is not
+ * active.</p>
+ */
+ <div id="cfg-Ext.form.ComboBox-valueField"></div>/**
+ * @cfg {String} valueField The underlying {@link Ext.data.Field#name data value name} to bind to this
+ * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field2'</tt> if
+ * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on
+ * the store configuration}).
+ * <p><b>Note</b>: use of a <tt>valueField</tt> requires the user to make a selection in order for a value to be
+ * mapped. See also <tt>{@link #hiddenName}</tt>, <tt>{@link #hiddenValue}</tt>, and <tt>{@link #displayField}</tt>.</p>
+ */
+ <div id="cfg-Ext.form.ComboBox-hiddenName"></div>/**
+ * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
+ * field's data value (defaults to the underlying DOM element's name). Required for the combo's value to automatically
+ * post during a form submission. See also {@link #valueField}.
+ * <p><b>Note</b>: the hidden field's id will also default to this name if {@link #hiddenId} is not specified.
+ * The ComboBox {@link Ext.Component#id id} and the <tt>{@link #hiddenId}</tt> <b>should be different</b>, since
+ * no two DOM nodes should share the same id. So, if the ComboBox <tt>{@link Ext.form.Field#name name}</tt> and
+ * <tt>hiddenName</tt> are the same, you should specify a unique <tt>{@link #hiddenId}</tt>.</p>
+ */
+ <div id="cfg-Ext.form.ComboBox-hiddenId"></div>/**
+ * @cfg {String} hiddenId If <tt>{@link #hiddenName}</tt> is specified, <tt>hiddenId</tt> can also be provided
+ * to give the hidden field a unique id (defaults to the <tt>{@link #hiddenName}</tt>). The <tt>hiddenId</tt>
+ * and combo {@link Ext.Component#id id} should be different, since no two DOM
+ * nodes should share the same id.
+ */
+ <div id="cfg-Ext.form.ComboBox-hiddenValue"></div>/**
+ * @cfg {String} hiddenValue Sets the initial value of the hidden field if {@link #hiddenName} is
+ * specified to contain the selected {@link #valueField}, from the Store. Defaults to the configured
+ * <tt>{@link Ext.form.Field#value value}</tt>.
+ */
+ <div id="cfg-Ext.form.ComboBox-listClass"></div>/**
+ * @cfg {String} listClass The CSS class to add to the predefined <tt>'x-combo-list'</tt> class
+ * applied the dropdown list element (defaults to '').
+ */
+ listClass : '',
+ <div id="cfg-Ext.form.ComboBox-selectedClass"></div>/**
+ * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list
+ * (defaults to <tt>'x-combo-selected'</tt>)
+ */
+ selectedClass : 'x-combo-selected',
+ <div id="cfg-Ext.form.ComboBox-listEmptyText"></div>/**
+ * @cfg {String} listEmptyText The empty text to display in the data view if no items are found.
+ * (defaults to '')
+ */
+ listEmptyText: '',
+ <div id="cfg-Ext.form.ComboBox-triggerClass"></div>/**
+ * @cfg {String} triggerClass An additional CSS class used to style the trigger button. The trigger will always
+ * get the class <tt>'x-form-trigger'</tt> and <tt>triggerClass</tt> will be <b>appended</b> if specified
+ * (defaults to <tt>'x-form-arrow-trigger'</tt> which displays a downward arrow icon).
+ */
+ triggerClass : 'x-form-arrow-trigger',
+ <div id="cfg-Ext.form.ComboBox-shadow"></div>/**
+ * @cfg {Boolean/String} shadow <tt>true</tt> or <tt>"sides"</tt> for the default effect, <tt>"frame"</tt> for
+ * 4-way shadow, and <tt>"drop"</tt> for bottom-right
+ */
+ shadow : 'sides',
+ <div id="cfg-Ext.form.ComboBox-listAlign"></div>/**
+ * @cfg {String/Array} listAlign A valid anchor position value. See <tt>{@link Ext.Element#alignTo}</tt> for details
+ * on supported anchor positions and offsets. To specify x/y offsets as well, this value
+ * may be specified as an Array of <tt>{@link Ext.Element#alignTo}</tt> method arguments.</p>
+ * <pre><code>[ 'tl-bl?', [6,0] ]</code></pre>(defaults to <tt>'tl-bl?'</tt>)
+ */
+ listAlign : 'tl-bl?',
+ <div id="cfg-Ext.form.ComboBox-maxHeight"></div>/**
+ * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown
+ * (defaults to <tt>300</tt>)
+ */
+ maxHeight : 300,
+ <div id="cfg-Ext.form.ComboBox-minHeight"></div>/**
+ * @cfg {Number} minHeight The minimum height in pixels of the dropdown list when the list is constrained by its
+ * distance to the viewport edges (defaults to <tt>90</tt>)
+ */
+ minHeight : 90,
+ <div id="cfg-Ext.form.ComboBox-triggerAction"></div>/**
+ * @cfg {String} triggerAction The action to execute when the trigger is clicked.
+ * <div class="mdetail-params"><ul>
+ * <li><b><tt>'query'</tt></b> : <b>Default</b>
+ * <p class="sub-desc">{@link #doQuery run the query} using the {@link Ext.form.Field#getRawValue raw value}.</p></li>
+ * <li><b><tt>'all'</tt></b> :
+ * <p class="sub-desc">{@link #doQuery run the query} specified by the <tt>{@link #allQuery}</tt> config option</p></li>
+ * </ul></div>
+ * <p>See also <code>{@link #queryParam}</code>.</p>
+ */
+ triggerAction : 'query',
+ <div id="cfg-Ext.form.ComboBox-minChars"></div>/**
+ * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and
+ * {@link #typeAhead} activate (defaults to <tt>4</tt> if <tt>{@link #mode} = 'remote'</tt> or <tt>0</tt> if
+ * <tt>{@link #mode} = 'local'</tt>, does not apply if
+ * <tt>{@link Ext.form.TriggerField#editable editable} = false</tt>).
+ */
+ minChars : 4,
+ <div id="cfg-Ext.form.ComboBox-autoSelect"></div>/**
+ * @cfg {Boolean} autoSelect <tt>true</tt> to select the first result gathered by the data store (defaults
+ * to <tt>true</tt>). A false value would require a manual selection from the dropdown list to set the components value
+ * unless the value of ({@link #typeAheadDelay}) were true.
+ */
+ autoSelect : true,
+ <div id="cfg-Ext.form.ComboBox-typeAhead"></div>/**
+ * @cfg {Boolean} typeAhead <tt>true</tt> to populate and autoselect the remainder of the text being
+ * typed after a configurable delay ({@link #typeAheadDelay}) if it matches a known value (defaults
+ * to <tt>false</tt>)
+ */
+ typeAhead : false,
+ <div id="cfg-Ext.form.ComboBox-queryDelay"></div>/**
+ * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and
+ * sending the query to filter the dropdown list (defaults to <tt>500</tt> if <tt>{@link #mode} = 'remote'</tt>
+ * or <tt>10</tt> if <tt>{@link #mode} = 'local'</tt>)
+ */
+ queryDelay : 500,
+ <div id="cfg-Ext.form.ComboBox-pageSize"></div>/**
+ * @cfg {Number} pageSize If greater than <tt>0</tt>, a {@link Ext.PagingToolbar} is displayed in the
+ * footer of the dropdown list and the {@link #doQuery filter queries} will execute with page start and
+ * {@link Ext.PagingToolbar#pageSize limit} parameters. Only applies when <tt>{@link #mode} = 'remote'</tt>
+ * (defaults to <tt>0</tt>).
+ */
+ pageSize : 0,
+ <div id="cfg-Ext.form.ComboBox-selectOnFocus"></div>/**
+ * @cfg {Boolean} selectOnFocus <tt>true</tt> to select any existing text in the field immediately on focus.
+ * Only applies when <tt>{@link Ext.form.TriggerField#editable editable} = true</tt> (defaults to
+ * <tt>false</tt>).
+ */
+ selectOnFocus : false,
+ <div id="cfg-Ext.form.ComboBox-queryParam"></div>/**
+ * @cfg {String} queryParam Name of the query ({@link Ext.data.Store#baseParam baseParam} name for the store)
+ * as it will be passed on the querystring (defaults to <tt>'query'</tt>)
+ */
+ queryParam : 'query',
+ <div id="cfg-Ext.form.ComboBox-loadingText"></div>/**
+ * @cfg {String} loadingText The text to display in the dropdown list while data is loading. Only applies
+ * when <tt>{@link #mode} = 'remote'</tt> (defaults to <tt>'Loading...'</tt>)
+ */
+ loadingText : 'Loading...',
+ <div id="cfg-Ext.form.ComboBox-resizable"></div>/**
+ * @cfg {Boolean} resizable <tt>true</tt> to add a resize handle to the bottom of the dropdown list
+ * (creates an {@link Ext.Resizable} with 'se' {@link Ext.Resizable#pinned pinned} handles).
+ * Defaults to <tt>false</tt>.
+ */
+ resizable : false,
+ <div id="cfg-Ext.form.ComboBox-handleHeight"></div>/**
+ * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if
+ * <tt>{@link #resizable} = true</tt> (defaults to <tt>8</tt>)
+ */
+ handleHeight : 8,
+ <div id="cfg-Ext.form.ComboBox-allQuery"></div>/**
+ * @cfg {String} allQuery The text query to send to the server to return all records for the list
+ * with no filtering (defaults to '')
+ */
+ allQuery: '',
+ <div id="cfg-Ext.form.ComboBox-mode"></div>/**
+ * @cfg {String} mode Acceptable values are:
+ * <div class="mdetail-params"><ul>
+ * <li><b><tt>'remote'</tt></b> : <b>Default</b>
+ * <p class="sub-desc">Automatically loads the <tt>{@link #store}</tt> the <b>first</b> time the trigger
+ * is clicked. If you do not want the store to be automatically loaded the first time the trigger is
+ * clicked, set to <tt>'local'</tt> and manually load the store. To force a requery of the store
+ * <b>every</b> time the trigger is clicked see <tt>{@link #lastQuery}</tt>.</p></li>
+ * <li><b><tt>'local'</tt></b> :
+ * <p class="sub-desc">ComboBox loads local data</p>
+ * <pre><code>
+var combo = new Ext.form.ComboBox({
+ renderTo: document.body,
+ mode: 'local',
+ store: new Ext.data.ArrayStore({
+ id: 0,
+ fields: [
+ 'myId', // numeric value is the key
+ 'displayText'
+ ],
+ data: [[1, 'item1'], [2, 'item2']] // data is local
+ }),
+ valueField: 'myId',
+ displayField: 'displayText',
+ triggerAction: 'all'
+});
+ * </code></pre></li>
+ * </ul></div>
+ */
+ mode: 'remote',
+ <div id="cfg-Ext.form.ComboBox-minListWidth"></div>/**
+ * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to <tt>70</tt>, will
+ * be ignored if <tt>{@link #listWidth}</tt> has a higher value)
+ */
+ minListWidth : 70,
+ <div id="cfg-Ext.form.ComboBox-forceSelection"></div>/**
+ * @cfg {Boolean} forceSelection <tt>true</tt> to restrict the selected value to one of the values in the list,
+ * <tt>false</tt> to allow the user to set arbitrary text into the field (defaults to <tt>false</tt>)
+ */
+ forceSelection : false,
+ <div id="cfg-Ext.form.ComboBox-typeAheadDelay"></div>/**
+ * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
+ * if <tt>{@link #typeAhead} = true</tt> (defaults to <tt>250</tt>)
+ */
+ typeAheadDelay : 250,
+ <div id="cfg-Ext.form.ComboBox-valueNotFoundText"></div>/**
+ * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
+ * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined). If this
+ * default text is used, it means there is no value set and no validation will occur on this field.
+ */
+
+ <div id="cfg-Ext.form.ComboBox-lazyInit"></div>/**
+ * @cfg {Boolean} lazyInit <tt>true</tt> to not initialize the list for this combo until the field is focused
+ * (defaults to <tt>true</tt>)
+ */
+ lazyInit : true,
+
+ <div id="cfg-Ext.form.ComboBox-clearFilterOnReset"></div>/**
+ * @cfg {Boolean} clearFilterOnReset <tt>true</tt> to clear any filters on the store (when in local mode) when reset is called
+ * (defaults to <tt>true</tt>)
+ */
+ clearFilterOnReset : true,
+
+ <div id="cfg-Ext.form.ComboBox-submitValue"></div>/**
+ * @cfg {Boolean} submitValue False to clear the name attribute on the field so that it is not submitted during a form post.
+ * If a hiddenName is specified, setting this to true will cause both the hidden field and the element to be submitted.
+ * Defaults to <tt>undefined</tt>.
+ */
+ submitValue: undefined,
+
+ <div id="prop-Ext.form.ComboBox-lastQuery"></div>/**
+ * The value of the match string used to filter the store. Delete this property to force a requery.
+ * Example use:
+ * <pre><code>
+var combo = new Ext.form.ComboBox({
+ ...
+ mode: 'remote',
+ ...
+ listeners: {
+ // delete the previous query in the beforequery event or set
+ // combo.lastQuery = null (this will reload the store the next time it expands)
+ beforequery: function(qe){
+ delete qe.combo.lastQuery;
+ }
+ }
+});
+ * </code></pre>
+ * To make sure the filter in the store is not cleared the first time the ComboBox trigger is used
+ * configure the combo with <tt>lastQuery=''</tt>. Example use:
+ * <pre><code>
+var combo = new Ext.form.ComboBox({
+ ...
+ mode: 'local',
+ triggerAction: 'all',
+ lastQuery: ''
+});
+ * </code></pre>
+ * @property lastQuery
+ * @type String
+ */
+
+ // private
+ initComponent : function(){
+ Ext.form.ComboBox.superclass.initComponent.call(this);
+ this.addEvents(
+ <div id="event-Ext.form.ComboBox-expand"></div>/**
+ * @event expand
+ * Fires when the dropdown list is expanded
+ * @param {Ext.form.ComboBox} combo This combo box
+ */
+ 'expand',
+ <div id="event-Ext.form.ComboBox-collapse"></div>/**
+ * @event collapse
+ * Fires when the dropdown list is collapsed
+ * @param {Ext.form.ComboBox} combo This combo box
+ */
+ 'collapse',
+
+ <div id="event-Ext.form.ComboBox-beforeselect"></div>/**
+ * @event beforeselect
+ * Fires before a list item is selected. Return false to cancel the selection.
+ * @param {Ext.form.ComboBox} combo This combo box
+ * @param {Ext.data.Record} record The data record returned from the underlying store
+ * @param {Number} index The index of the selected item in the dropdown list
+ */
+ 'beforeselect',
+ <div id="event-Ext.form.ComboBox-select"></div>/**
+ * @event select
+ * Fires when a list item is selected
+ * @param {Ext.form.ComboBox} combo This combo box
+ * @param {Ext.data.Record} record The data record returned from the underlying store
+ * @param {Number} index The index of the selected item in the dropdown list
+ */
+ 'select',
+ <div id="event-Ext.form.ComboBox-beforequery"></div>/**
+ * @event beforequery
+ * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's
+ * cancel property to true.
+ * @param {Object} queryEvent An object that has these properties:<ul>
+ * <li><code>combo</code> : Ext.form.ComboBox <div class="sub-desc">This combo box</div></li>
+ * <li><code>query</code> : String <div class="sub-desc">The query</div></li>
+ * <li><code>forceAll</code> : Boolean <div class="sub-desc">True to force "all" query</div></li>
+ * <li><code>cancel</code> : Boolean <div class="sub-desc">Set to true to cancel the query</div></li>
+ * </ul>
+ */
+ 'beforequery'
+ );
+ if(this.transform){
+ var s = Ext.getDom(this.transform);
+ if(!this.hiddenName){
+ this.hiddenName = s.name;
+ }
+ if(!this.store){
+ this.mode = 'local';
+ var d = [], opts = s.options;
+ for(var i = 0, len = opts.length;i < len; i++){
+ var o = opts[i],
+ value = (o.hasAttribute ? o.hasAttribute('value') : o.getAttributeNode('value').specified) ? o.value : o.text;
+ if(o.selected && Ext.isEmpty(this.value, true)) {
+ this.value = value;
+ }
+ d.push([value, o.text]);
+ }
+ this.store = new Ext.data.ArrayStore({
+ 'id': 0,
+ fields: ['value', 'text'],
+ data : d,
+ autoDestroy: true
+ });
+ this.valueField = 'value';
+ this.displayField = 'text';
+ }
+ s.name = Ext.id(); // wipe out the name in case somewhere else they have a reference
+ if(!this.lazyRender){
+ this.target = true;
+ this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
+ this.render(this.el.parentNode, s);
+ }
+ Ext.removeNode(s);
+ }
+ //auto-configure store from local array data
+ else if(this.store){
+ this.store = Ext.StoreMgr.lookup(this.store);
+ if(this.store.autoCreated){
+ this.displayField = this.valueField = 'field1';
+ if(!this.store.expandData){
+ this.displayField = 'field2';
+ }
+ this.mode = 'local';
+ }
+ }
+
+ this.selectedIndex = -1;
+ if(this.mode == 'local'){
+ if(!Ext.isDefined(this.initialConfig.queryDelay)){
+ this.queryDelay = 10;
+ }
+ if(!Ext.isDefined(this.initialConfig.minChars)){
+ this.minChars = 0;
+ }
+ }
+ },
+
+ // private
+ onRender : function(ct, position){
+ if(this.hiddenName && !Ext.isDefined(this.submitValue)){
+ this.submitValue = false;
+ }
+ Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
+ if(this.hiddenName){
+ this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
+ id: (this.hiddenId||this.hiddenName)}, 'before', true);
+
+ }
+ if(Ext.isGecko){
+ this.el.dom.setAttribute('autocomplete', 'off');
+ }
+
+ if(!this.lazyInit){
+ this.initList();
+ }else{
+ this.on('focus', this.initList, this, {single: true});
+ }
+ },
+
+ // private
+ initValue : function(){
+ Ext.form.ComboBox.superclass.initValue.call(this);
+ if(this.hiddenField){
+ this.hiddenField.value =
+ Ext.value(Ext.isDefined(this.hiddenValue) ? this.hiddenValue : this.value, '');
+ }
+ },
+
+ getParentZIndex : function(){
+ var zindex;
+ if (this.ownerCt){
+ this.findParentBy(function(ct){
+ zindex = parseInt(ct.getPositionEl().getStyle('z-index'), 10);
+ return !!zindex;
+ });
+ }
+ return zindex;
+ },
+
+ // private
+ initList : function(){
+ if(!this.list){
+ var cls = 'x-combo-list',
+ listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
+ zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10);
+
+ if (!zindex) {
+ zindex = this.getParentZIndex();
+ }
+
+ this.list = new Ext.Layer({
+ parentEl: listParent,
+ shadow: this.shadow,
+ cls: [cls, this.listClass].join(' '),
+ constrain:false,
+ zindex: (zindex || 12000) + 5
+ });
+
+ var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
+ this.list.setSize(lw, 0);
+ this.list.swallowEvent('mousewheel');
+ this.assetHeight = 0;
+ if(this.syncFont !== false){
+ this.list.setStyle('font-size', this.el.getStyle('font-size'));
+ }
+ if(this.title){
+ this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
+ this.assetHeight += this.header.getHeight();
+ }
+
+ this.innerList = this.list.createChild({cls:cls+'-inner'});
+ this.mon(this.innerList, 'mouseover', this.onViewOver, this);
+ this.mon(this.innerList, 'mousemove', this.onViewMove, this);
+ this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
+
+ if(this.pageSize){
+ this.footer = this.list.createChild({cls:cls+'-ft'});
+ this.pageTb = new Ext.PagingToolbar({
+ store: this.store,
+ pageSize: this.pageSize,
+ renderTo:this.footer
+ });
+ this.assetHeight += this.footer.getHeight();
+ }
+
+ if(!this.tpl){
+ <div id="cfg-Ext.form.ComboBox-tpl"></div>/**
+ * @cfg {String/Ext.XTemplate} tpl <p>The template string, or {@link Ext.XTemplate} instance to
+ * use to display each item in the dropdown list. The dropdown list is displayed in a
+ * DataView. See {@link #view}.</p>
+ * <p>The default template string is:</p><pre><code>
+ '<tpl for="."><div class="x-combo-list-item">{' + this.displayField + '}</div></tpl>'
+ * </code></pre>
+ * <p>Override the default value to create custom UI layouts for items in the list.
+ * For example:</p><pre><code>
+ '<tpl for="."><div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}</div></tpl>'
+ * </code></pre>
+ * <p>The template <b>must</b> contain one or more substitution parameters using field
+ * names from the Combo's</b> {@link #store Store}. In the example above an
+ * <pre>ext:qtip</pre> attribute is added to display other fields from the Store.</p>
+ * <p>To preserve the default visual look of list items, add the CSS class name
+ * <pre>x-combo-list-item</pre> to the template's container element.</p>
+ * <p>Also see {@link #itemSelector} for additional details.</p>
+ */
+ this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
+ <div id="cfg-Ext.form.ComboBox-itemSelector"></div>/**
+ * @cfg {String} itemSelector
+ * <p>A simple CSS selector (e.g. div.some-class or span:first-child) that will be
+ * used to determine what nodes the {@link #view Ext.DataView} which handles the dropdown
+ * display will be working with.</p>
+ * <p><b>Note</b>: this setting is <b>required</b> if a custom XTemplate has been
+ * specified in {@link #tpl} which assigns a class other than <pre>'x-combo-list-item'</pre>
+ * to dropdown list items</b>
+ */
+ }
+
+ <div id="prop-Ext.form.ComboBox-view"></div>/**
+ * The {@link Ext.DataView DataView} used to display the ComboBox's options.
+ * @type Ext.DataView
+ */
+ this.view = new Ext.DataView({
+ applyTo: this.innerList,
+ tpl: this.tpl,
+ singleSelect: true,
+ selectedClass: this.selectedClass,
+ itemSelector: this.itemSelector || '.' + cls + '-item',
+ emptyText: this.listEmptyText,
+ deferEmptyText: false
+ });
+
+ this.mon(this.view, {
+ containerclick : this.onViewClick,
+ click : this.onViewClick,
+ scope :this
+ });
+
+ this.bindStore(this.store, true);
+
+ if(this.resizable){
+ this.resizer = new Ext.Resizable(this.list, {
+ pinned:true, handles:'se'
+ });
+ this.mon(this.resizer, 'resize', function(r, w, h){
+ this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
+ this.listWidth = w;
+ this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
+ this.restrictHeight();
+ }, this);
+
+ this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
+ }
+ }
+ },
+
+ <div id="method-Ext.form.ComboBox-getListParent"></div>/**
+ * <p>Returns the element used to house this ComboBox's pop-up list. Defaults to the document body.</p>
+ * A custom implementation may be provided as a configuration option if the floating list needs to be rendered
+ * to a different Element. An example might be rendering the list inside a Menu so that clicking
+ * the list does not hide the Menu:<pre><code>
+var store = new Ext.data.ArrayStore({
+ autoDestroy: true,
+ fields: ['initials', 'fullname'],
+ data : [
+ ['FF', 'Fred Flintstone'],
+ ['BR', 'Barney Rubble']
+ ]
+});
+
+var combo = new Ext.form.ComboBox({
+ store: store,
+ displayField: 'fullname',
+ emptyText: 'Select a name...',
+ forceSelection: true,
+ getListParent: function() {
+ return this.el.up('.x-menu');
+ },
+ iconCls: 'no-icon', //use iconCls if placing within menu to shift to right side of menu
+ mode: 'local',
+ selectOnFocus: true,
+ triggerAction: 'all',
+ typeAhead: true,
+ width: 135
+});
+
+var menu = new Ext.menu.Menu({
+ id: 'mainMenu',
+ items: [
+ combo // A Field in a Menu
+ ]
+});
+</code></pre>
+ */
+ getListParent : function() {
+ return document.body;
+ },
+
+ <div id="method-Ext.form.ComboBox-getStore"></div>/**
+ * Returns the store associated with this combo.
+ * @return {Ext.data.Store} The store
+ */
+ getStore : function(){
+ return this.store;
+ },
+
+ // private
+ bindStore : function(store, initial){
+ if(this.store && !initial){
+ if(this.store !== store && this.store.autoDestroy){
+ this.store.destroy();
+ }else{
+ this.store.un('beforeload', this.onBeforeLoad, this);
+ this.store.un('load', this.onLoad, this);
+ this.store.un('exception', this.collapse, this);
+ }
+ if(!store){
+ this.store = null;
+ if(this.view){
+ this.view.bindStore(null);
+ }
+ if(this.pageTb){
+ this.pageTb.bindStore(null);
+ }
+ }
+ }
+ if(store){
+ if(!initial) {
+ this.lastQuery = null;
+ if(this.pageTb) {
+ this.pageTb.bindStore(store);
+ }
+ }
+
+ this.store = Ext.StoreMgr.lookup(store);
+ this.store.on({
+ scope: this,
+ beforeload: this.onBeforeLoad,
+ load: this.onLoad,
+ exception: this.collapse
+ });
+
+ if(this.view){
+ this.view.bindStore(store);
+ }
+ }
+ },
+
+ reset : function(){
+ Ext.form.ComboBox.superclass.reset.call(this);
+ if(this.clearFilterOnReset && this.mode == 'local'){
+ this.store.clearFilter();
+ }
+ },
+
+ // private
+ initEvents : function(){
+ Ext.form.ComboBox.superclass.initEvents.call(this);
+
+ <div id="prop-Ext.form.ComboBox-keyNav"></div>/**
+ * @property keyNav
+ * @type Ext.KeyNav
+ * <p>A {@link Ext.KeyNav KeyNav} object which handles navigation keys for this ComboBox. This performs actions
+ * based on keystrokes typed when the input field is focused.</p>
+ * <p><b>After the ComboBox has been rendered</b>, you may override existing navigation key functionality,
+ * or add your own based upon key names as specified in the {@link Ext.KeyNav KeyNav} class.</p>
+ * <p>The function is executed in the scope (<code>this</code> reference of the ComboBox. Example:</p><pre><code>
+myCombo.keyNav.esc = function(e) { // Override ESC handling function
+ this.collapse(); // Standard behaviour of Ext's ComboBox.
+ this.setValue(this.startValue); // We reset to starting value on ESC
+};
+myCombo.keyNav.tab = function() { // Override TAB handling function
+ this.onViewClick(false); // Select the currently highlighted row
+};
+</code></pre>
+ */
+ this.keyNav = new Ext.KeyNav(this.el, {
+ "up" : function(e){
+ this.inKeyMode = true;
+ this.selectPrev();
+ },
+
+ "down" : function(e){
+ if(!this.isExpanded()){
+ this.onTriggerClick();
+ }else{
+ this.inKeyMode = true;
+ this.selectNext();
+ }
+ },
+
+ "enter" : function(e){
+ this.onViewClick();
+ },
+
+ "esc" : function(e){
+ this.collapse();
+ },
+
+ "tab" : function(e){
+ if (this.forceSelection === true) {
+ this.collapse();
+ } else {
+ this.onViewClick(false);
+ }
+ return true;
+ },
+
+ scope : this,
+
+ doRelay : function(e, h, hname){
+ if(hname == 'down' || this.scope.isExpanded()){
+ // this MUST be called before ComboBox#fireKey()
+ var relay = Ext.KeyNav.prototype.doRelay.apply(this, arguments);
+ if(!Ext.isIE && Ext.EventManager.useKeydown){
+ // call Combo#fireKey() for browsers which use keydown event (except IE)
+ this.scope.fireKey(e);
+ }
+ return relay;
+ }
+ return true;
+ },
+
+ forceKeyDown : true,
+ defaultEventAction: 'stopEvent'
+ });
+ this.queryDelay = Math.max(this.queryDelay || 10,
+ this.mode == 'local' ? 10 : 250);
+ this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
+ if(this.typeAhead){
+ this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
+ }
+ if(!this.enableKeyEvents){
+ this.mon(this.el, 'keyup', this.onKeyUp, this);
+ }
+ },
+
+
+ // private
+ onDestroy : function(){
+ if (this.dqTask){
+ this.dqTask.cancel();
+ this.dqTask = null;
+ }
+ this.bindStore(null);
+ Ext.destroy(
+ this.resizer,
+ this.view,
+ this.pageTb,
+ this.list
+ );
+ Ext.destroyMembers(this, 'hiddenField');
+ Ext.form.ComboBox.superclass.onDestroy.call(this);
+ },
+
+ // private
+ fireKey : function(e){
+ if (!this.isExpanded()) {
+ Ext.form.ComboBox.superclass.fireKey.call(this, e);
+ }
+ },
+
+ // private
+ onResize : function(w, h){
+ Ext.form.ComboBox.superclass.onResize.apply(this, arguments);
+ if(!isNaN(w) && this.isVisible() && this.list){
+ this.doResize(w);
+ }else{
+ this.bufferSize = w;
+ }
+ },
+
+ doResize: function(w){
+ if(!Ext.isDefined(this.listWidth)){
+ var lw = Math.max(w, this.minListWidth);
+ this.list.setWidth(lw);
+ this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
+ }
+ },
+
+ // private
+ onEnable : function(){
+ Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
+ if(this.hiddenField){
+ this.hiddenField.disabled = false;
+ }
+ },
+
+ // private
+ onDisable : function(){
+ Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
+ if(this.hiddenField){
+ this.hiddenField.disabled = true;
+ }
+ },
+
+ // private
+ onBeforeLoad : function(){
+ if(!this.hasFocus){
+ return;
+ }
+ this.innerList.update(this.loadingText ?
+ '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
+ this.restrictHeight();
+ this.selectedIndex = -1;
+ },
+
+ // private
+ onLoad : function(){
+ if(!this.hasFocus){
+ return;
+ }
+ if(this.store.getCount() > 0 || this.listEmptyText){
+ this.expand();
+ this.restrictHeight();
+ if(this.lastQuery == this.allQuery){
+ if(this.editable){
+ this.el.dom.select();
+ }
+
+ if(this.autoSelect !== false && !this.selectByValue(this.value, true)){
+ this.select(0, true);
+ }
+ }else{
+ if(this.autoSelect !== false){
+ this.selectNext();
+ }
+ if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
+ this.taTask.delay(this.typeAheadDelay);
+ }
+ }
+ }else{
+ this.collapse();
+ }
+
+ },
+
+ // private
+ onTypeAhead : function(){
+ if(this.store.getCount() > 0){
+ var r = this.store.getAt(0);
+ var newValue = r.data[this.displayField];
+ var len = newValue.length;
+ var selStart = this.getRawValue().length;
+ if(selStart != len){
+ this.setRawValue(newValue);
+ this.selectText(selStart, newValue.length);
+ }
+ }
+ },
+
+ // private
+ assertValue : function(){
+ var val = this.getRawValue(),
+ rec = this.findRecord(this.displayField, val);
+
+ if(!rec && this.forceSelection){
+ if(val.length > 0 && val != this.emptyText){
+ this.el.dom.value = Ext.value(this.lastSelectionText, '');
+ this.applyEmptyText();
+ }else{
+ this.clearValue();
+ }
+ }else{
+ if(rec){
+ // onSelect may have already set the value and by doing so
+ // set the display field properly. Let's not wipe out the
+ // valueField here by just sending the displayField.
+ if (val == rec.get(this.displayField) && this.value == rec.get(this.valueField)){
+ return;
+ }
+ val = rec.get(this.valueField || this.displayField);
+ }
+ this.setValue(val);
+ }
+ },
+
+ // private
+ onSelect : function(record, index){
+ if(this.fireEvent('beforeselect', this, record, index) !== false){
+ this.setValue(record.data[this.valueField || this.displayField]);
+ this.collapse();
+ this.fireEvent('select', this, record, index);
+ }
+ },
+
+ // inherit docs
+ getName: function(){
+ var hf = this.hiddenField;
+ return hf && hf.name ? hf.name : this.hiddenName || Ext.form.ComboBox.superclass.getName.call(this);
+ },
+
+ <div id="method-Ext.form.ComboBox-getValue"></div>/**
+ * Returns the currently selected field value or empty string if no value is set.
+ * @return {String} value The selected value
+ */
+ getValue : function(){
+ if(this.valueField){
+ return Ext.isDefined(this.value) ? this.value : '';
+ }else{
+ return Ext.form.ComboBox.superclass.getValue.call(this);
+ }
+ },
+
+ <div id="method-Ext.form.ComboBox-clearValue"></div>/**
+ * Clears any text/value currently set in the field
+ */
+ clearValue : function(){
+ if(this.hiddenField){
+ this.hiddenField.value = '';
+ }
+ this.setRawValue('');
+ this.lastSelectionText = '';
+ this.applyEmptyText();
+ this.value = '';
+ },
+
+ <div id="method-Ext.form.ComboBox-setValue"></div>/**
+ * Sets the specified value into the field. If the value finds a match, the corresponding record text
+ * will be displayed in the field. If the value does not match the data value of an existing item,
+ * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
+ * Otherwise the field will be blank (although the value will still be set).
+ * @param {String} value The value to match
+ * @return {Ext.form.Field} this
+ */
+ setValue : function(v){
+ var text = v;
+ if(this.valueField){
+ var r = this.findRecord(this.valueField, v);
+ if(r){
+ text = r.data[this.displayField];
+ }else if(Ext.isDefined(this.valueNotFoundText)){
+ text = this.valueNotFoundText;
+ }
+ }
+ this.lastSelectionText = text;
+ if(this.hiddenField){
+ this.hiddenField.value = Ext.value(v, '');
+ }
+ Ext.form.ComboBox.superclass.setValue.call(this, text);
+ this.value = v;
+ return this;
+ },
+
+ // private
+ findRecord : function(prop, value){
+ var record;
+ if(this.store.getCount() > 0){
+ this.store.each(function(r){
+ if(r.data[prop] == value){
+ record = r;
+ return false;
+ }
+ });
+ }
+ return record;
+ },
+
+ // private
+ onViewMove : function(e, t){
+ this.inKeyMode = false;
+ },
+
+ // private
+ onViewOver : function(e, t){
+ if(this.inKeyMode){ // prevent key nav and mouse over conflicts
+ return;
+ }
+ var item = this.view.findItemFromChild(t);
+ if(item){
+ var index = this.view.indexOf(item);
+ this.select(index, false);
+ }
+ },
+
+ // private
+ onViewClick : function(doFocus){
+ var index = this.view.getSelectedIndexes()[0],
+ s = this.store,
+ r = s.getAt(index);
+ if(r){
+ this.onSelect(r, index);
+ }else {
+ this.collapse();
+ }
+ if(doFocus !== false){
+ this.el.focus();
+ }
+ },
+
+
+ // private
+ restrictHeight : function(){
+ this.innerList.dom.style.height = '';
+ var inner = this.innerList.dom,
+ pad = this.list.getFrameWidth('tb') + (this.resizable ? this.handleHeight : 0) + this.assetHeight,
+ h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight),
+ ha = this.getPosition()[1]-Ext.getBody().getScroll().top,
+ hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height,
+ space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
+
+ h = Math.min(h, space, this.maxHeight);
+
+ this.innerList.setHeight(h);
+ this.list.beginUpdate();
+ this.list.setHeight(h+pad);
+ this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
+ this.list.endUpdate();
+ },
+
+ <div id="method-Ext.form.ComboBox-isExpanded"></div>/**
+ * Returns true if the dropdown list is expanded, else false.
+ */
+ isExpanded : function(){
+ return this.list && this.list.isVisible();
+ },
+
+ <div id="method-Ext.form.ComboBox-selectByValue"></div>/**
+ * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
+ * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
+ * @param {String} value The data value of the item to select
+ * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
+ * selected item if it is not currently in view (defaults to true)
+ * @return {Boolean} True if the value matched an item in the list, else false
+ */
+ selectByValue : function(v, scrollIntoView){
+ if(!Ext.isEmpty(v, true)){
+ var r = this.findRecord(this.valueField || this.displayField, v);
+ if(r){
+ this.select(this.store.indexOf(r), scrollIntoView);
+ return true;
+ }
+ }
+ return false;
+ },
+
+ <div id="method-Ext.form.ComboBox-select"></div>/**
+ * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
+ * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
+ * @param {Number} index The zero-based index of the list item to select
+ * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
+ * selected item if it is not currently in view (defaults to true)
+ */
+ select : function(index, scrollIntoView){
+ this.selectedIndex = index;
+ this.view.select(index);
+ if(scrollIntoView !== false){
+ var el = this.view.getNode(index);
+ if(el){
+ this.innerList.scrollChildIntoView(el, false);
+ }
+ }
+
+ },
+
+ // private
+ selectNext : function(){
+ var ct = this.store.getCount();
+ if(ct > 0){
+ if(this.selectedIndex == -1){
+ this.select(0);
+ }else if(this.selectedIndex < ct-1){
+ this.select(this.selectedIndex+1);
+ }
+ }
+ },
+
+ // private
+ selectPrev : function(){
+ var ct = this.store.getCount();
+ if(ct > 0){
+ if(this.selectedIndex == -1){
+ this.select(0);
+ }else if(this.selectedIndex !== 0){
+ this.select(this.selectedIndex-1);
+ }
+ }
+ },
+
+ // private
+ onKeyUp : function(e){
+ var k = e.getKey();
+ if(this.editable !== false && this.readOnly !== true && (k == e.BACKSPACE || !e.isSpecialKey())){
+
+ this.lastKey = k;
+ this.dqTask.delay(this.queryDelay);
+ }
+ Ext.form.ComboBox.superclass.onKeyUp.call(this, e);
+ },
+
+ // private
+ validateBlur : function(){
+ return !this.list || !this.list.isVisible();
+ },
+
+ // private
+ initQuery : function(){
+ this.doQuery(this.getRawValue());
+ },
+
+ // private
+ beforeBlur : function(){
+ this.assertValue();
+ },
+
+ // private
+ postBlur : function(){
+ Ext.form.ComboBox.superclass.postBlur.call(this);
+ this.collapse();
+ this.inKeyMode = false;
+ },
+
+ <div id="method-Ext.form.ComboBox-doQuery"></div>/**
+ * Execute a query to filter the dropdown list. Fires the {@link #beforequery} event prior to performing the
+ * query allowing the query action to be canceled if needed.
+ * @param {String} query The SQL query to execute
+ * @param {Boolean} forceAll <tt>true</tt> to force the query to execute even if there are currently fewer
+ * characters in the field than the minimum specified by the <tt>{@link #minChars}</tt> config option. It
+ * also clears any filter previously saved in the current store (defaults to <tt>false</tt>)
+ */
+ doQuery : function(q, forceAll){
+ q = Ext.isEmpty(q) ? '' : q;
+ var qe = {
+ query: q,
+ forceAll: forceAll,
+ combo: this,
+ cancel:false
+ };
+ if(this.fireEvent('beforequery', qe)===false || qe.cancel){
+ return false;
+ }
+ q = qe.query;
+ forceAll = qe.forceAll;
+ if(forceAll === true || (q.length >= this.minChars)){
+ if(this.lastQuery !== q){
+ this.lastQuery = q;
+ if(this.mode == 'local'){
+ this.selectedIndex = -1;
+ if(forceAll){
+ this.store.clearFilter();
+ }else{
+ this.store.filter(this.displayField, q);
+ }
+ this.onLoad();
+ }else{
+ this.store.baseParams[this.queryParam] = q;
+ this.store.load({
+ params: this.getParams(q)
+ });
+ this.expand();
+ }
+ }else{
+ this.selectedIndex = -1;
+ this.onLoad();
+ }
+ }
+ },
+
+ // private
+ getParams : function(q){
+ var p = {};
+ //p[this.queryParam] = q;
+ if(this.pageSize){
+ p.start = 0;
+ p.limit = this.pageSize;
+ }
+ return p;
+ },
+
+ <div id="method-Ext.form.ComboBox-collapse"></div>/**
+ * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.
+ */
+ collapse : function(){
+ if(!this.isExpanded()){
+ return;
+ }
+ this.list.hide();
+ Ext.getDoc().un('mousewheel', this.collapseIf, this);
+ Ext.getDoc().un('mousedown', this.collapseIf, this);
+ this.fireEvent('collapse', this);
+ },
+
+ // private
+ collapseIf : function(e){
+ if(!this.isDestroyed && !e.within(this.wrap) && !e.within(this.list)){
+ this.collapse();
+ }
+ },
+
+ <div id="method-Ext.form.ComboBox-expand"></div>/**
+ * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.
+ */
+ expand : function(){
+ if(this.isExpanded() || !this.hasFocus){
+ return;
+ }
+
+ if(this.title || this.pageSize){
+ this.assetHeight = 0;
+ if(this.title){
+ this.assetHeight += this.header.getHeight();
+ }
+ if(this.pageSize){
+ this.assetHeight += this.footer.getHeight();
+ }
+ }
+
+ if(this.bufferSize){
+ this.doResize(this.bufferSize);
+ delete this.bufferSize;
+ }
+ this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
+
+ // zindex can change, re-check it and set it if necessary
+ var listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
+ zindex = parseInt(Ext.fly(listParent).getStyle('z-index') ,10);
+ if (!zindex){
+ zindex = this.getParentZIndex();
+ }
+ if (zindex) {
+ this.list.setZIndex(zindex + 5);
+ }
+ this.list.show();
+ if(Ext.isGecko2){
+ this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac
+ }
+ this.mon(Ext.getDoc(), {
+ scope: this,
+ mousewheel: this.collapseIf,
+ mousedown: this.collapseIf
+ });
+ this.fireEvent('expand', this);
+ },
+
+ <div id="method-Ext.form.ComboBox-onTriggerClick"></div>/**
+ * @method onTriggerClick
+ * @hide
+ */
+ // private
+ // Implements the default empty TriggerField.onTriggerClick function
+ onTriggerClick : function(){
+ if(this.readOnly || this.disabled){
+ return;
+ }
+ if(this.isExpanded()){
+ this.collapse();
+ this.el.focus();
+ }else {
+ this.onFocus({});
+ if(this.triggerAction == 'all') {
+ this.doQuery(this.allQuery, true);
+ } else {
+ this.doQuery(this.getRawValue());
+ }
+ this.el.focus();
+ }
+ }
+
+ <div id="method-Ext.form.ComboBox-autoSize"></div>/**
+ * @hide
+ * @method autoSize
+ */
+ <div id="cfg-Ext.form.ComboBox-grow"></div>/**
+ * @cfg {Boolean} grow @hide
+ */
+ <div id="cfg-Ext.form.ComboBox-growMin"></div>/**
+ * @cfg {Number} growMin @hide
+ */
+ <div id="cfg-Ext.form.ComboBox-growMax"></div>/**
+ * @cfg {Number} growMax @hide
+ */
+
+});
+Ext.reg('combo', Ext.form.ComboBox);
+</pre>
</body>
</html>
\ No newline at end of file