Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / src / widgets / form / Combo.js
1 /*!
2  * Ext JS Library 3.2.1
3  * Copyright(c) 2006-2010 Ext JS, Inc.
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 /**
8  * @class Ext.form.ComboBox
9  * @extends Ext.form.TriggerField
10  * <p>A combobox control with support for autocomplete, remote-loading, paging and many other features.</p>
11  * <p>A ComboBox works in a similar manner to a traditional HTML &lt;select> field. The difference is
12  * that to submit the {@link #valueField}, you must specify a {@link #hiddenName} to create a hidden input
13  * field to hold the value of the valueField. The <i>{@link #displayField}</i> is shown in the text field
14  * which is named according to the {@link #name}.</p>
15  * <p><b><u>Events</u></b></p>
16  * <p>To do something when something in ComboBox is selected, configure the select event:<pre><code>
17 var cb = new Ext.form.ComboBox({
18     // all of your config options
19     listeners:{
20          scope: yourScope,
21          'select': yourFunction
22     }
23 });
24
25 // Alternatively, you can assign events after the object is created:
26 var cb = new Ext.form.ComboBox(yourOptions);
27 cb.on('select', yourFunction, yourScope);
28  * </code></pre></p>
29  *
30  * <p><b><u>ComboBox in Grid</u></b></p>
31  * <p>If using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a {@link Ext.grid.Column#renderer renderer}
32  * will be needed to show the displayField when the editor is not active.  Set up the renderer manually, or implement
33  * a reusable render, for example:<pre><code>
34 // create reusable renderer
35 Ext.util.Format.comboRenderer = function(combo){
36     return function(value){
37         var record = combo.findRecord(combo.{@link #valueField}, value);
38         return record ? record.get(combo.{@link #displayField}) : combo.{@link #valueNotFoundText};
39     }
40 }
41
42 // create the combo instance
43 var combo = new Ext.form.ComboBox({
44     {@link #typeAhead}: true,
45     {@link #triggerAction}: 'all',
46     {@link #lazyRender}:true,
47     {@link #mode}: 'local',
48     {@link #store}: new Ext.data.ArrayStore({
49         id: 0,
50         fields: [
51             'myId',
52             'displayText'
53         ],
54         data: [[1, 'item1'], [2, 'item2']]
55     }),
56     {@link #valueField}: 'myId',
57     {@link #displayField}: 'displayText'
58 });
59
60 // snippet of column model used within grid
61 var cm = new Ext.grid.ColumnModel([{
62        ...
63     },{
64        header: "Some Header",
65        dataIndex: 'whatever',
66        width: 130,
67        editor: combo, // specify reference to combo instance
68        renderer: Ext.util.Format.comboRenderer(combo) // pass combo instance to reusable renderer
69     },
70     ...
71 ]);
72  * </code></pre></p>
73  *
74  * <p><b><u>Filtering</u></b></p>
75  * <p>A ComboBox {@link #doQuery uses filtering itself}, for information about filtering the ComboBox
76  * store manually see <tt>{@link #lastQuery}</tt>.</p>
77  * @constructor
78  * Create a new ComboBox.
79  * @param {Object} config Configuration options
80  * @xtype combo
81  */
82 Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {
83     /**
84      * @cfg {Mixed} transform The id, DOM node or element of an existing HTML SELECT to convert to a ComboBox.
85      * Note that if you specify this and the combo is going to be in an {@link Ext.form.BasicForm} or
86      * {@link Ext.form.FormPanel}, you must also set <tt>{@link #lazyRender} = true</tt>.
87      */
88     /**
89      * @cfg {Boolean} lazyRender <tt>true</tt> to prevent the ComboBox from rendering until requested
90      * (should always be used when rendering into an {@link Ext.Editor} (e.g. {@link Ext.grid.EditorGridPanel Grids}),
91      * defaults to <tt>false</tt>).
92      */
93     /**
94      * @cfg {String/Object} autoCreate <p>A {@link Ext.DomHelper DomHelper} element spec, or <tt>true</tt> for a default
95      * element spec. Used to create the {@link Ext.Component#getEl Element} which will encapsulate this Component.
96      * See <tt>{@link Ext.Component#autoEl autoEl}</tt> for details.  Defaults to:</p>
97      * <pre><code>{tag: "input", type: "text", size: "24", autocomplete: "off"}</code></pre>
98      */
99     /**
100      * @cfg {Ext.data.Store/Array} store The data source to which this combo is bound (defaults to <tt>undefined</tt>).
101      * Acceptable values for this property are:
102      * <div class="mdetail-params"><ul>
103      * <li><b>any {@link Ext.data.Store Store} subclass</b></li>
104      * <li><b>an Array</b> : Arrays will be converted to a {@link Ext.data.ArrayStore} internally,
105      * automatically generating {@link Ext.data.Field#name field names} to work with all data components.
106      * <div class="mdetail-params"><ul>
107      * <li><b>1-dimensional array</b> : (e.g., <tt>['Foo','Bar']</tt>)<div class="sub-desc">
108      * A 1-dimensional array will automatically be expanded (each array item will be used for both the combo
109      * {@link #valueField} and {@link #displayField})</div></li>
110      * <li><b>2-dimensional array</b> : (e.g., <tt>[['f','Foo'],['b','Bar']]</tt>)<div class="sub-desc">
111      * For a multi-dimensional array, the value in index 0 of each item will be assumed to be the combo
112      * {@link #valueField}, while the value at index 1 is assumed to be the combo {@link #displayField}.
113      * </div></li></ul></div></li></ul></div>
114      * <p>See also <tt>{@link #mode}</tt>.</p>
115      */
116     /**
117      * @cfg {String} title If supplied, a header element is created containing this text and added into the top of
118      * the dropdown list (defaults to undefined, with no header element)
119      */
120
121     // private
122     defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
123     /**
124      * @cfg {Number} listWidth The width (used as a parameter to {@link Ext.Element#setWidth}) of the dropdown
125      * list (defaults to the width of the ComboBox field).  See also <tt>{@link #minListWidth}
126      */
127     /**
128      * @cfg {String} displayField The underlying {@link Ext.data.Field#name data field name} to bind to this
129      * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field1'</tt> if
130      * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on
131      * the store configuration}).
132      * <p>See also <tt>{@link #valueField}</tt>.</p>
133      * <p><b>Note</b>: if using a ComboBox in an {@link Ext.grid.EditorGridPanel Editor Grid} a
134      * {@link Ext.grid.Column#renderer renderer} will be needed to show the displayField when the editor is not
135      * active.</p>
136      */
137     /**
138      * @cfg {String} valueField The underlying {@link Ext.data.Field#name data value name} to bind to this
139      * ComboBox (defaults to undefined if <tt>{@link #mode} = 'remote'</tt> or <tt>'field2'</tt> if
140      * {@link #transform transforming a select} or if the {@link #store field name is autogenerated based on
141      * the store configuration}).
142      * <p><b>Note</b>: use of a <tt>valueField</tt> requires the user to make a selection in order for a value to be
143      * mapped.  See also <tt>{@link #hiddenName}</tt>, <tt>{@link #hiddenValue}</tt>, and <tt>{@link #displayField}</tt>.</p>
144      */
145     /**
146      * @cfg {String} hiddenName If specified, a hidden form field with this name is dynamically generated to store the
147      * field's data value (defaults to the underlying DOM element's name). Required for the combo's value to automatically
148      * post during a form submission.  See also {@link #valueField}.
149      * <p><b>Note</b>: the hidden field's id will also default to this name if {@link #hiddenId} is not specified.
150      * The ComboBox {@link Ext.Component#id id} and the <tt>{@link #hiddenId}</tt> <b>should be different</b>, since
151      * no two DOM nodes should share the same id.  So, if the ComboBox <tt>{@link Ext.form.Field#name name}</tt> and
152      * <tt>hiddenName</tt> are the same, you should specify a unique <tt>{@link #hiddenId}</tt>.</p>
153      */
154     /**
155      * @cfg {String} hiddenId If <tt>{@link #hiddenName}</tt> is specified, <tt>hiddenId</tt> can also be provided
156      * to give the hidden field a unique id (defaults to the <tt>{@link #hiddenName}</tt>).  The <tt>hiddenId</tt>
157      * and combo {@link Ext.Component#id id} should be different, since no two DOM
158      * nodes should share the same id.
159      */
160     /**
161      * @cfg {String} hiddenValue Sets the initial value of the hidden field if {@link #hiddenName} is
162      * specified to contain the selected {@link #valueField}, from the Store. Defaults to the configured
163      * <tt>{@link Ext.form.Field#value value}</tt>.
164      */
165     /**
166      * @cfg {String} listClass The CSS class to add to the predefined <tt>'x-combo-list'</tt> class
167      * applied the dropdown list element (defaults to '').
168      */
169     listClass : '',
170     /**
171      * @cfg {String} selectedClass CSS class to apply to the selected item in the dropdown list
172      * (defaults to <tt>'x-combo-selected'</tt>)
173      */
174     selectedClass : 'x-combo-selected',
175     /**
176      * @cfg {String} listEmptyText The empty text to display in the data view if no items are found.
177      * (defaults to '')
178      */
179     listEmptyText: '',
180     /**
181      * @cfg {String} triggerClass An additional CSS class used to style the trigger button.  The trigger will always
182      * get the class <tt>'x-form-trigger'</tt> and <tt>triggerClass</tt> will be <b>appended</b> if specified
183      * (defaults to <tt>'x-form-arrow-trigger'</tt> which displays a downward arrow icon).
184      */
185     triggerClass : 'x-form-arrow-trigger',
186     /**
187      * @cfg {Boolean/String} shadow <tt>true</tt> or <tt>"sides"</tt> for the default effect, <tt>"frame"</tt> for
188      * 4-way shadow, and <tt>"drop"</tt> for bottom-right
189      */
190     shadow : 'sides',
191     /**
192      * @cfg {String/Array} listAlign A valid anchor position value. See <tt>{@link Ext.Element#alignTo}</tt> for details
193      * on supported anchor positions and offsets. To specify x/y offsets as well, this value
194      * may be specified as an Array of <tt>{@link Ext.Element#alignTo}</tt> method arguments.</p>
195      * <pre><code>[ 'tl-bl?', [6,0] ]</code></pre>(defaults to <tt>'tl-bl?'</tt>)
196      */
197     listAlign : 'tl-bl?',
198     /**
199      * @cfg {Number} maxHeight The maximum height in pixels of the dropdown list before scrollbars are shown
200      * (defaults to <tt>300</tt>)
201      */
202     maxHeight : 300,
203     /**
204      * @cfg {Number} minHeight The minimum height in pixels of the dropdown list when the list is constrained by its
205      * distance to the viewport edges (defaults to <tt>90</tt>)
206      */
207     minHeight : 90,
208     /**
209      * @cfg {String} triggerAction The action to execute when the trigger is clicked.
210      * <div class="mdetail-params"><ul>
211      * <li><b><tt>'query'</tt></b> : <b>Default</b>
212      * <p class="sub-desc">{@link #doQuery run the query} using the {@link Ext.form.Field#getRawValue raw value}.</p></li>
213      * <li><b><tt>'all'</tt></b> :
214      * <p class="sub-desc">{@link #doQuery run the query} specified by the <tt>{@link #allQuery}</tt> config option</p></li>
215      * </ul></div>
216      * <p>See also <code>{@link #queryParam}</code>.</p>
217      */
218     triggerAction : 'query',
219     /**
220      * @cfg {Number} minChars The minimum number of characters the user must type before autocomplete and
221      * {@link #typeAhead} activate (defaults to <tt>4</tt> if <tt>{@link #mode} = 'remote'</tt> or <tt>0</tt> if
222      * <tt>{@link #mode} = 'local'</tt>, does not apply if
223      * <tt>{@link Ext.form.TriggerField#editable editable} = false</tt>).
224      */
225     minChars : 4,
226     /**
227      * @cfg {Boolean} autoSelect <tt>true</tt> to select the first result gathered by the data store (defaults
228      * to <tt>true</tt>).  A false value would require a manual selection from the dropdown list to set the components value
229      * unless the value of ({@link #typeAheadDelay}) were true.
230      */
231     autoSelect : true,
232     /**
233      * @cfg {Boolean} typeAhead <tt>true</tt> to populate and autoselect the remainder of the text being
234      * typed after a configurable delay ({@link #typeAheadDelay}) if it matches a known value (defaults
235      * to <tt>false</tt>)
236      */
237     typeAhead : false,
238     /**
239      * @cfg {Number} queryDelay The length of time in milliseconds to delay between the start of typing and
240      * sending the query to filter the dropdown list (defaults to <tt>500</tt> if <tt>{@link #mode} = 'remote'</tt>
241      * or <tt>10</tt> if <tt>{@link #mode} = 'local'</tt>)
242      */
243     queryDelay : 500,
244     /**
245      * @cfg {Number} pageSize If greater than <tt>0</tt>, a {@link Ext.PagingToolbar} is displayed in the
246      * footer of the dropdown list and the {@link #doQuery filter queries} will execute with page start and
247      * {@link Ext.PagingToolbar#pageSize limit} parameters. Only applies when <tt>{@link #mode} = 'remote'</tt>
248      * (defaults to <tt>0</tt>).
249      */
250     pageSize : 0,
251     /**
252      * @cfg {Boolean} selectOnFocus <tt>true</tt> to select any existing text in the field immediately on focus.
253      * Only applies when <tt>{@link Ext.form.TriggerField#editable editable} = true</tt> (defaults to
254      * <tt>false</tt>).
255      */
256     selectOnFocus : false,
257     /**
258      * @cfg {String} queryParam Name of the query ({@link Ext.data.Store#baseParam baseParam} name for the store)
259      * as it will be passed on the querystring (defaults to <tt>'query'</tt>)
260      */
261     queryParam : 'query',
262     /**
263      * @cfg {String} loadingText The text to display in the dropdown list while data is loading.  Only applies
264      * when <tt>{@link #mode} = 'remote'</tt> (defaults to <tt>'Loading...'</tt>)
265      */
266     loadingText : 'Loading...',
267     /**
268      * @cfg {Boolean} resizable <tt>true</tt> to add a resize handle to the bottom of the dropdown list
269      * (creates an {@link Ext.Resizable} with 'se' {@link Ext.Resizable#pinned pinned} handles).
270      * Defaults to <tt>false</tt>.
271      */
272     resizable : false,
273     /**
274      * @cfg {Number} handleHeight The height in pixels of the dropdown list resize handle if
275      * <tt>{@link #resizable} = true</tt> (defaults to <tt>8</tt>)
276      */
277     handleHeight : 8,
278     /**
279      * @cfg {String} allQuery The text query to send to the server to return all records for the list
280      * with no filtering (defaults to '')
281      */
282     allQuery: '',
283     /**
284      * @cfg {String} mode Acceptable values are:
285      * <div class="mdetail-params"><ul>
286      * <li><b><tt>'remote'</tt></b> : <b>Default</b>
287      * <p class="sub-desc">Automatically loads the <tt>{@link #store}</tt> the <b>first</b> time the trigger
288      * is clicked. If you do not want the store to be automatically loaded the first time the trigger is
289      * clicked, set to <tt>'local'</tt> and manually load the store.  To force a requery of the store
290      * <b>every</b> time the trigger is clicked see <tt>{@link #lastQuery}</tt>.</p></li>
291      * <li><b><tt>'local'</tt></b> :
292      * <p class="sub-desc">ComboBox loads local data</p>
293      * <pre><code>
294 var combo = new Ext.form.ComboBox({
295     renderTo: document.body,
296     mode: 'local',
297     store: new Ext.data.ArrayStore({
298         id: 0,
299         fields: [
300             'myId',  // numeric value is the key
301             'displayText'
302         ],
303         data: [[1, 'item1'], [2, 'item2']]  // data is local
304     }),
305     valueField: 'myId',
306     displayField: 'displayText',
307     triggerAction: 'all'
308 });
309      * </code></pre></li>
310      * </ul></div>
311      */
312     mode: 'remote',
313     /**
314      * @cfg {Number} minListWidth The minimum width of the dropdown list in pixels (defaults to <tt>70</tt>, will
315      * be ignored if <tt>{@link #listWidth}</tt> has a higher value)
316      */
317     minListWidth : 70,
318     /**
319      * @cfg {Boolean} forceSelection <tt>true</tt> to restrict the selected value to one of the values in the list,
320      * <tt>false</tt> to allow the user to set arbitrary text into the field (defaults to <tt>false</tt>)
321      */
322     forceSelection : false,
323     /**
324      * @cfg {Number} typeAheadDelay The length of time in milliseconds to wait until the typeahead text is displayed
325      * if <tt>{@link #typeAhead} = true</tt> (defaults to <tt>250</tt>)
326      */
327     typeAheadDelay : 250,
328     /**
329      * @cfg {String} valueNotFoundText When using a name/value combo, if the value passed to setValue is not found in
330      * the store, valueNotFoundText will be displayed as the field text if defined (defaults to undefined). If this
331      * default text is used, it means there is no value set and no validation will occur on this field.
332      */
333
334     /**
335      * @cfg {Boolean} lazyInit <tt>true</tt> to not initialize the list for this combo until the field is focused
336      * (defaults to <tt>true</tt>)
337      */
338     lazyInit : true,
339
340     /**
341      * @cfg {Boolean} clearFilterOnReset <tt>true</tt> to clear any filters on the store (when in local mode) when reset is called
342      * (defaults to <tt>true</tt>)
343      */
344     clearFilterOnReset : true,
345
346     /**
347      * @cfg {Boolean} submitValue False to clear the name attribute on the field so that it is not submitted during a form post.
348      * If a hiddenName is specified, setting this to true will cause both the hidden field and the element to be submitted.
349      * Defaults to <tt>undefined</tt>.
350      */
351     submitValue: undefined,
352
353     /**
354      * The value of the match string used to filter the store. Delete this property to force a requery.
355      * Example use:
356      * <pre><code>
357 var combo = new Ext.form.ComboBox({
358     ...
359     mode: 'remote',
360     ...
361     listeners: {
362         // delete the previous query in the beforequery event or set
363         // combo.lastQuery = null (this will reload the store the next time it expands)
364         beforequery: function(qe){
365             delete qe.combo.lastQuery;
366         }
367     }
368 });
369      * </code></pre>
370      * To make sure the filter in the store is not cleared the first time the ComboBox trigger is used
371      * configure the combo with <tt>lastQuery=''</tt>. Example use:
372      * <pre><code>
373 var combo = new Ext.form.ComboBox({
374     ...
375     mode: 'local',
376     triggerAction: 'all',
377     lastQuery: ''
378 });
379      * </code></pre>
380      * @property lastQuery
381      * @type String
382      */
383
384     // private
385     initComponent : function(){
386         Ext.form.ComboBox.superclass.initComponent.call(this);
387         this.addEvents(
388             /**
389              * @event expand
390              * Fires when the dropdown list is expanded
391              * @param {Ext.form.ComboBox} combo This combo box
392              */
393             'expand',
394             /**
395              * @event collapse
396              * Fires when the dropdown list is collapsed
397              * @param {Ext.form.ComboBox} combo This combo box
398              */
399             'collapse',
400
401             /**
402              * @event beforeselect
403              * Fires before a list item is selected. Return false to cancel the selection.
404              * @param {Ext.form.ComboBox} combo This combo box
405              * @param {Ext.data.Record} record The data record returned from the underlying store
406              * @param {Number} index The index of the selected item in the dropdown list
407              */
408             'beforeselect',
409             /**
410              * @event select
411              * Fires when a list item is selected
412              * @param {Ext.form.ComboBox} combo This combo box
413              * @param {Ext.data.Record} record The data record returned from the underlying store
414              * @param {Number} index The index of the selected item in the dropdown list
415              */
416             'select',
417             /**
418              * @event beforequery
419              * Fires before all queries are processed. Return false to cancel the query or set the queryEvent's
420              * cancel property to true.
421              * @param {Object} queryEvent An object that has these properties:<ul>
422              * <li><code>combo</code> : Ext.form.ComboBox <div class="sub-desc">This combo box</div></li>
423              * <li><code>query</code> : String <div class="sub-desc">The query</div></li>
424              * <li><code>forceAll</code> : Boolean <div class="sub-desc">True to force "all" query</div></li>
425              * <li><code>cancel</code> : Boolean <div class="sub-desc">Set to true to cancel the query</div></li>
426              * </ul>
427              */
428             'beforequery'
429         );
430         if(this.transform){
431             var s = Ext.getDom(this.transform);
432             if(!this.hiddenName){
433                 this.hiddenName = s.name;
434             }
435             if(!this.store){
436                 this.mode = 'local';
437                 var d = [], opts = s.options;
438                 for(var i = 0, len = opts.length;i < len; i++){
439                     var o = opts[i],
440                         value = (o.hasAttribute ? o.hasAttribute('value') : o.getAttributeNode('value').specified) ? o.value : o.text;
441                     if(o.selected && Ext.isEmpty(this.value, true)) {
442                         this.value = value;
443                     }
444                     d.push([value, o.text]);
445                 }
446                 this.store = new Ext.data.ArrayStore({
447                     'id': 0,
448                     fields: ['value', 'text'],
449                     data : d,
450                     autoDestroy: true
451                 });
452                 this.valueField = 'value';
453                 this.displayField = 'text';
454             }
455             s.name = Ext.id(); // wipe out the name in case somewhere else they have a reference
456             if(!this.lazyRender){
457                 this.target = true;
458                 this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
459                 this.render(this.el.parentNode, s);
460             }
461             Ext.removeNode(s);
462         }
463         //auto-configure store from local array data
464         else if(this.store){
465             this.store = Ext.StoreMgr.lookup(this.store);
466             if(this.store.autoCreated){
467                 this.displayField = this.valueField = 'field1';
468                 if(!this.store.expandData){
469                     this.displayField = 'field2';
470                 }
471                 this.mode = 'local';
472             }
473         }
474
475         this.selectedIndex = -1;
476         if(this.mode == 'local'){
477             if(!Ext.isDefined(this.initialConfig.queryDelay)){
478                 this.queryDelay = 10;
479             }
480             if(!Ext.isDefined(this.initialConfig.minChars)){
481                 this.minChars = 0;
482             }
483         }
484     },
485
486     // private
487     onRender : function(ct, position){
488         if(this.hiddenName && !Ext.isDefined(this.submitValue)){
489             this.submitValue = false;
490         }
491         Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
492         if(this.hiddenName){
493             this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName,
494                     id: (this.hiddenId||this.hiddenName)}, 'before', true);
495
496         }
497         if(Ext.isGecko){
498             this.el.dom.setAttribute('autocomplete', 'off');
499         }
500
501         if(!this.lazyInit){
502             this.initList();
503         }else{
504             this.on('focus', this.initList, this, {single: true});
505         }
506     },
507
508     // private
509     initValue : function(){
510         Ext.form.ComboBox.superclass.initValue.call(this);
511         if(this.hiddenField){
512             this.hiddenField.value =
513                 Ext.value(Ext.isDefined(this.hiddenValue) ? this.hiddenValue : this.value, '');
514         }
515     },
516
517     getParentZIndex : function(){
518         var zindex;
519         if (this.ownerCt){
520             this.findParentBy(function(ct){
521                 zindex = parseInt(ct.getPositionEl().getStyle('z-index'), 10);
522                 return !!zindex;
523             });
524         }
525         return zindex;
526     },
527
528     // private
529     initList : function(){
530         if(!this.list){
531             var cls = 'x-combo-list',
532                 listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
533                 zindex = parseInt(Ext.fly(listParent).getStyle('z-index'), 10);
534
535             if (!zindex) {
536                 zindex = this.getParentZIndex();
537             }
538
539             this.list = new Ext.Layer({
540                 parentEl: listParent,
541                 shadow: this.shadow,
542                 cls: [cls, this.listClass].join(' '),
543                 constrain:false,
544                 zindex: (zindex || 12000) + 5
545             });
546
547             var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
548             this.list.setSize(lw, 0);
549             this.list.swallowEvent('mousewheel');
550             this.assetHeight = 0;
551             if(this.syncFont !== false){
552                 this.list.setStyle('font-size', this.el.getStyle('font-size'));
553             }
554             if(this.title){
555                 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
556                 this.assetHeight += this.header.getHeight();
557             }
558
559             this.innerList = this.list.createChild({cls:cls+'-inner'});
560             this.mon(this.innerList, 'mouseover', this.onViewOver, this);
561             this.mon(this.innerList, 'mousemove', this.onViewMove, this);
562             this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
563
564             if(this.pageSize){
565                 this.footer = this.list.createChild({cls:cls+'-ft'});
566                 this.pageTb = new Ext.PagingToolbar({
567                     store: this.store,
568                     pageSize: this.pageSize,
569                     renderTo:this.footer
570                 });
571                 this.assetHeight += this.footer.getHeight();
572             }
573
574             if(!this.tpl){
575                 /**
576                 * @cfg {String/Ext.XTemplate} tpl <p>The template string, or {@link Ext.XTemplate} instance to
577                 * use to display each item in the dropdown list. The dropdown list is displayed in a
578                 * DataView. See {@link #view}.</p>
579                 * <p>The default template string is:</p><pre><code>
580                   '&lt;tpl for=".">&lt;div class="x-combo-list-item">{' + this.displayField + '}&lt;/div>&lt;/tpl>'
581                 * </code></pre>
582                 * <p>Override the default value to create custom UI layouts for items in the list.
583                 * For example:</p><pre><code>
584                   '&lt;tpl for=".">&lt;div ext:qtip="{state}. {nick}" class="x-combo-list-item">{state}&lt;/div>&lt;/tpl>'
585                 * </code></pre>
586                 * <p>The template <b>must</b> contain one or more substitution parameters using field
587                 * names from the Combo's</b> {@link #store Store}. In the example above an
588                 * <pre>ext:qtip</pre> attribute is added to display other fields from the Store.</p>
589                 * <p>To preserve the default visual look of list items, add the CSS class name
590                 * <pre>x-combo-list-item</pre> to the template's container element.</p>
591                 * <p>Also see {@link #itemSelector} for additional details.</p>
592                 */
593                 this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
594                 /**
595                  * @cfg {String} itemSelector
596                  * <p>A simple CSS selector (e.g. div.some-class or span:first-child) that will be
597                  * used to determine what nodes the {@link #view Ext.DataView} which handles the dropdown
598                  * display will be working with.</p>
599                  * <p><b>Note</b>: this setting is <b>required</b> if a custom XTemplate has been
600                  * specified in {@link #tpl} which assigns a class other than <pre>'x-combo-list-item'</pre>
601                  * to dropdown list items</b>
602                  */
603             }
604
605             /**
606             * The {@link Ext.DataView DataView} used to display the ComboBox's options.
607             * @type Ext.DataView
608             */
609             this.view = new Ext.DataView({
610                 applyTo: this.innerList,
611                 tpl: this.tpl,
612                 singleSelect: true,
613                 selectedClass: this.selectedClass,
614                 itemSelector: this.itemSelector || '.' + cls + '-item',
615                 emptyText: this.listEmptyText,
616                 deferEmptyText: false
617             });
618
619             this.mon(this.view, {
620                 containerclick : this.onViewClick,
621                 click : this.onViewClick,
622                 scope :this
623             });
624
625             this.bindStore(this.store, true);
626
627             if(this.resizable){
628                 this.resizer = new Ext.Resizable(this.list,  {
629                    pinned:true, handles:'se'
630                 });
631                 this.mon(this.resizer, 'resize', function(r, w, h){
632                     this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
633                     this.listWidth = w;
634                     this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
635                     this.restrictHeight();
636                 }, this);
637
638                 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
639             }
640         }
641     },
642
643     /**
644      * <p>Returns the element used to house this ComboBox's pop-up list. Defaults to the document body.</p>
645      * A custom implementation may be provided as a configuration option if the floating list needs to be rendered
646      * to a different Element. An example might be rendering the list inside a Menu so that clicking
647      * the list does not hide the Menu:<pre><code>
648 var store = new Ext.data.ArrayStore({
649     autoDestroy: true,
650     fields: ['initials', 'fullname'],
651     data : [
652         ['FF', 'Fred Flintstone'],
653         ['BR', 'Barney Rubble']
654     ]
655 });
656
657 var combo = new Ext.form.ComboBox({
658     store: store,
659     displayField: 'fullname',
660     emptyText: 'Select a name...',
661     forceSelection: true,
662     getListParent: function() {
663         return this.el.up('.x-menu');
664     },
665     iconCls: 'no-icon', //use iconCls if placing within menu to shift to right side of menu
666     mode: 'local',
667     selectOnFocus: true,
668     triggerAction: 'all',
669     typeAhead: true,
670     width: 135
671 });
672
673 var menu = new Ext.menu.Menu({
674     id: 'mainMenu',
675     items: [
676         combo // A Field in a Menu
677     ]
678 });
679 </code></pre>
680      */
681     getListParent : function() {
682         return document.body;
683     },
684
685     /**
686      * Returns the store associated with this combo.
687      * @return {Ext.data.Store} The store
688      */
689     getStore : function(){
690         return this.store;
691     },
692
693     // private
694     bindStore : function(store, initial){
695         if(this.store && !initial){
696             if(this.store !== store && this.store.autoDestroy){
697                 this.store.destroy();
698             }else{
699                 this.store.un('beforeload', this.onBeforeLoad, this);
700                 this.store.un('load', this.onLoad, this);
701                 this.store.un('exception', this.collapse, this);
702             }
703             if(!store){
704                 this.store = null;
705                 if(this.view){
706                     this.view.bindStore(null);
707                 }
708                 if(this.pageTb){
709                     this.pageTb.bindStore(null);
710                 }
711             }
712         }
713         if(store){
714             if(!initial) {
715                 this.lastQuery = null;
716                 if(this.pageTb) {
717                     this.pageTb.bindStore(store);
718                 }
719             }
720
721             this.store = Ext.StoreMgr.lookup(store);
722             this.store.on({
723                 scope: this,
724                 beforeload: this.onBeforeLoad,
725                 load: this.onLoad,
726                 exception: this.collapse
727             });
728
729             if(this.view){
730                 this.view.bindStore(store);
731             }
732         }
733     },
734
735     reset : function(){
736         Ext.form.ComboBox.superclass.reset.call(this);
737         if(this.clearFilterOnReset && this.mode == 'local'){
738             this.store.clearFilter();
739         }
740     },
741
742     // private
743     initEvents : function(){
744         Ext.form.ComboBox.superclass.initEvents.call(this);
745
746         /**
747          * @property keyNav
748          * @type Ext.KeyNav
749          * <p>A {@link Ext.KeyNav KeyNav} object which handles navigation keys for this ComboBox. This performs actions
750          * based on keystrokes typed when the input field is focused.</p>
751          * <p><b>After the ComboBox has been rendered</b>, you may override existing navigation key functionality,
752          * or add your own based upon key names as specified in the {@link Ext.KeyNav KeyNav} class.</p>
753          * <p>The function is executed in the scope (<code>this</code> reference of the ComboBox. Example:</p><pre><code>
754 myCombo.keyNav.esc = function(e) {  // Override ESC handling function
755     this.collapse();                // Standard behaviour of Ext's ComboBox.
756     this.setValue(this.startValue); // We reset to starting value on ESC
757 };
758 myCombo.keyNav.tab = function() {   // Override TAB handling function
759     this.onViewClick(false);        // Select the currently highlighted row
760 };
761 </code></pre>
762          */
763         this.keyNav = new Ext.KeyNav(this.el, {
764             "up" : function(e){
765                 this.inKeyMode = true;
766                 this.selectPrev();
767             },
768
769             "down" : function(e){
770                 if(!this.isExpanded()){
771                     this.onTriggerClick();
772                 }else{
773                     this.inKeyMode = true;
774                     this.selectNext();
775                 }
776             },
777
778             "enter" : function(e){
779                 this.onViewClick();
780             },
781
782             "esc" : function(e){
783                 this.collapse();
784             },
785
786             "tab" : function(e){
787                 if (this.forceSelection === true) {
788                     this.collapse();
789                 } else {
790                     this.onViewClick(false);
791                 }
792                 return true;
793             },
794
795             scope : this,
796
797             doRelay : function(e, h, hname){
798                 if(hname == 'down' || this.scope.isExpanded()){
799                     // this MUST be called before ComboBox#fireKey()
800                     var relay = Ext.KeyNav.prototype.doRelay.apply(this, arguments);
801                     if(!Ext.isIE && Ext.EventManager.useKeydown){
802                         // call Combo#fireKey() for browsers which use keydown event (except IE)
803                         this.scope.fireKey(e);
804                     }
805                     return relay;
806                 }
807                 return true;
808             },
809
810             forceKeyDown : true,
811             defaultEventAction: 'stopEvent'
812         });
813         this.queryDelay = Math.max(this.queryDelay || 10,
814                 this.mode == 'local' ? 10 : 250);
815         this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
816         if(this.typeAhead){
817             this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
818         }
819         if(!this.enableKeyEvents){
820             this.mon(this.el, 'keyup', this.onKeyUp, this);
821         }
822     },
823
824
825     // private
826     onDestroy : function(){
827         if (this.dqTask){
828             this.dqTask.cancel();
829             this.dqTask = null;
830         }
831         this.bindStore(null);
832         Ext.destroy(
833             this.resizer,
834             this.view,
835             this.pageTb,
836             this.list
837         );
838         Ext.destroyMembers(this, 'hiddenField');
839         Ext.form.ComboBox.superclass.onDestroy.call(this);
840     },
841
842     // private
843     fireKey : function(e){
844         if (!this.isExpanded()) {
845             Ext.form.ComboBox.superclass.fireKey.call(this, e);
846         }
847     },
848
849     // private
850     onResize : function(w, h){
851         Ext.form.ComboBox.superclass.onResize.apply(this, arguments);
852         if(!isNaN(w) && this.isVisible() && this.list){
853             this.doResize(w);
854         }else{
855             this.bufferSize = w;
856         }
857     },
858
859     doResize: function(w){
860         if(!Ext.isDefined(this.listWidth)){
861             var lw = Math.max(w, this.minListWidth);
862             this.list.setWidth(lw);
863             this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
864         }
865     },
866
867     // private
868     onEnable : function(){
869         Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
870         if(this.hiddenField){
871             this.hiddenField.disabled = false;
872         }
873     },
874
875     // private
876     onDisable : function(){
877         Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
878         if(this.hiddenField){
879             this.hiddenField.disabled = true;
880         }
881     },
882
883     // private
884     onBeforeLoad : function(){
885         if(!this.hasFocus){
886             return;
887         }
888         this.innerList.update(this.loadingText ?
889                '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
890         this.restrictHeight();
891         this.selectedIndex = -1;
892     },
893
894     // private
895     onLoad : function(){
896         if(!this.hasFocus){
897             return;
898         }
899         if(this.store.getCount() > 0 || this.listEmptyText){
900             this.expand();
901             this.restrictHeight();
902             if(this.lastQuery == this.allQuery){
903                 if(this.editable){
904                     this.el.dom.select();
905                 }
906
907                 if(this.autoSelect !== false && !this.selectByValue(this.value, true)){
908                     this.select(0, true);
909                 }
910             }else{
911                 if(this.autoSelect !== false){
912                     this.selectNext();
913                 }
914                 if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
915                     this.taTask.delay(this.typeAheadDelay);
916                 }
917             }
918         }else{
919             this.collapse();
920         }
921
922     },
923
924     // private
925     onTypeAhead : function(){
926         if(this.store.getCount() > 0){
927             var r = this.store.getAt(0);
928             var newValue = r.data[this.displayField];
929             var len = newValue.length;
930             var selStart = this.getRawValue().length;
931             if(selStart != len){
932                 this.setRawValue(newValue);
933                 this.selectText(selStart, newValue.length);
934             }
935         }
936     },
937
938     // private
939     assertValue  : function(){
940         var val = this.getRawValue(),
941             rec = this.findRecord(this.displayField, val);
942
943         if(!rec && this.forceSelection){
944             if(val.length > 0 && val != this.emptyText){
945                 this.el.dom.value = Ext.value(this.lastSelectionText, '');
946                 this.applyEmptyText();
947             }else{
948                 this.clearValue();
949             }
950         }else{
951             if(rec){
952                 // onSelect may have already set the value and by doing so
953                 // set the display field properly.  Let's not wipe out the
954                 // valueField here by just sending the displayField.
955                 if (val == rec.get(this.displayField) && this.value == rec.get(this.valueField)){
956                     return;
957                 }
958                 val = rec.get(this.valueField || this.displayField);
959             }
960             this.setValue(val);
961         }
962     },
963
964     // private
965     onSelect : function(record, index){
966         if(this.fireEvent('beforeselect', this, record, index) !== false){
967             this.setValue(record.data[this.valueField || this.displayField]);
968             this.collapse();
969             this.fireEvent('select', this, record, index);
970         }
971     },
972
973     // inherit docs
974     getName: function(){
975         var hf = this.hiddenField;
976         return hf && hf.name ? hf.name : this.hiddenName || Ext.form.ComboBox.superclass.getName.call(this);
977     },
978
979     /**
980      * Returns the currently selected field value or empty string if no value is set.
981      * @return {String} value The selected value
982      */
983     getValue : function(){
984         if(this.valueField){
985             return Ext.isDefined(this.value) ? this.value : '';
986         }else{
987             return Ext.form.ComboBox.superclass.getValue.call(this);
988         }
989     },
990
991     /**
992      * Clears any text/value currently set in the field
993      */
994     clearValue : function(){
995         if(this.hiddenField){
996             this.hiddenField.value = '';
997         }
998         this.setRawValue('');
999         this.lastSelectionText = '';
1000         this.applyEmptyText();
1001         this.value = '';
1002     },
1003
1004     /**
1005      * Sets the specified value into the field.  If the value finds a match, the corresponding record text
1006      * will be displayed in the field.  If the value does not match the data value of an existing item,
1007      * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
1008      * Otherwise the field will be blank (although the value will still be set).
1009      * @param {String} value The value to match
1010      * @return {Ext.form.Field} this
1011      */
1012     setValue : function(v){
1013         var text = v;
1014         if(this.valueField){
1015             var r = this.findRecord(this.valueField, v);
1016             if(r){
1017                 text = r.data[this.displayField];
1018             }else if(Ext.isDefined(this.valueNotFoundText)){
1019                 text = this.valueNotFoundText;
1020             }
1021         }
1022         this.lastSelectionText = text;
1023         if(this.hiddenField){
1024             this.hiddenField.value = Ext.value(v, '');
1025         }
1026         Ext.form.ComboBox.superclass.setValue.call(this, text);
1027         this.value = v;
1028         return this;
1029     },
1030
1031     // private
1032     findRecord : function(prop, value){
1033         var record;
1034         if(this.store.getCount() > 0){
1035             this.store.each(function(r){
1036                 if(r.data[prop] == value){
1037                     record = r;
1038                     return false;
1039                 }
1040             });
1041         }
1042         return record;
1043     },
1044
1045     // private
1046     onViewMove : function(e, t){
1047         this.inKeyMode = false;
1048     },
1049
1050     // private
1051     onViewOver : function(e, t){
1052         if(this.inKeyMode){ // prevent key nav and mouse over conflicts
1053             return;
1054         }
1055         var item = this.view.findItemFromChild(t);
1056         if(item){
1057             var index = this.view.indexOf(item);
1058             this.select(index, false);
1059         }
1060     },
1061
1062     // private
1063     onViewClick : function(doFocus){
1064         var index = this.view.getSelectedIndexes()[0],
1065             s = this.store,
1066             r = s.getAt(index);
1067         if(r){
1068             this.onSelect(r, index);
1069         }else {
1070             this.collapse();
1071         }
1072         if(doFocus !== false){
1073             this.el.focus();
1074         }
1075     },
1076
1077
1078     // private
1079     restrictHeight : function(){
1080         this.innerList.dom.style.height = '';
1081         var inner = this.innerList.dom,
1082             pad = this.list.getFrameWidth('tb') + (this.resizable ? this.handleHeight : 0) + this.assetHeight,
1083             h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight),
1084             ha = this.getPosition()[1]-Ext.getBody().getScroll().top,
1085             hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height,
1086             space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadowOffset-pad-5;
1087
1088         h = Math.min(h, space, this.maxHeight);
1089
1090         this.innerList.setHeight(h);
1091         this.list.beginUpdate();
1092         this.list.setHeight(h+pad);
1093         this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
1094         this.list.endUpdate();
1095     },
1096
1097     /**
1098      * Returns true if the dropdown list is expanded, else false.
1099      */
1100     isExpanded : function(){
1101         return this.list && this.list.isVisible();
1102     },
1103
1104     /**
1105      * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
1106      * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1107      * @param {String} value The data value of the item to select
1108      * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1109      * selected item if it is not currently in view (defaults to true)
1110      * @return {Boolean} True if the value matched an item in the list, else false
1111      */
1112     selectByValue : function(v, scrollIntoView){
1113         if(!Ext.isEmpty(v, true)){
1114             var r = this.findRecord(this.valueField || this.displayField, v);
1115             if(r){
1116                 this.select(this.store.indexOf(r), scrollIntoView);
1117                 return true;
1118             }
1119         }
1120         return false;
1121     },
1122
1123     /**
1124      * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
1125      * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1126      * @param {Number} index The zero-based index of the list item to select
1127      * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1128      * selected item if it is not currently in view (defaults to true)
1129      */
1130     select : function(index, scrollIntoView){
1131         this.selectedIndex = index;
1132         this.view.select(index);
1133         if(scrollIntoView !== false){
1134             var el = this.view.getNode(index);
1135             if(el){
1136                 this.innerList.scrollChildIntoView(el, false);
1137             }
1138         }
1139
1140     },
1141
1142     // private
1143     selectNext : function(){
1144         var ct = this.store.getCount();
1145         if(ct > 0){
1146             if(this.selectedIndex == -1){
1147                 this.select(0);
1148             }else if(this.selectedIndex < ct-1){
1149                 this.select(this.selectedIndex+1);
1150             }
1151         }
1152     },
1153
1154     // private
1155     selectPrev : function(){
1156         var ct = this.store.getCount();
1157         if(ct > 0){
1158             if(this.selectedIndex == -1){
1159                 this.select(0);
1160             }else if(this.selectedIndex !== 0){
1161                 this.select(this.selectedIndex-1);
1162             }
1163         }
1164     },
1165
1166     // private
1167     onKeyUp : function(e){
1168         var k = e.getKey();
1169         if(this.editable !== false && this.readOnly !== true && (k == e.BACKSPACE || !e.isSpecialKey())){
1170
1171             this.lastKey = k;
1172             this.dqTask.delay(this.queryDelay);
1173         }
1174         Ext.form.ComboBox.superclass.onKeyUp.call(this, e);
1175     },
1176
1177     // private
1178     validateBlur : function(){
1179         return !this.list || !this.list.isVisible();
1180     },
1181
1182     // private
1183     initQuery : function(){
1184         this.doQuery(this.getRawValue());
1185     },
1186
1187     // private
1188     beforeBlur : function(){
1189         this.assertValue();
1190     },
1191
1192     // private
1193     postBlur  : function(){
1194         Ext.form.ComboBox.superclass.postBlur.call(this);
1195         this.collapse();
1196         this.inKeyMode = false;
1197     },
1198
1199     /**
1200      * Execute a query to filter the dropdown list.  Fires the {@link #beforequery} event prior to performing the
1201      * query allowing the query action to be canceled if needed.
1202      * @param {String} query The SQL query to execute
1203      * @param {Boolean} forceAll <tt>true</tt> to force the query to execute even if there are currently fewer
1204      * characters in the field than the minimum specified by the <tt>{@link #minChars}</tt> config option.  It
1205      * also clears any filter previously saved in the current store (defaults to <tt>false</tt>)
1206      */
1207     doQuery : function(q, forceAll){
1208         q = Ext.isEmpty(q) ? '' : q;
1209         var qe = {
1210             query: q,
1211             forceAll: forceAll,
1212             combo: this,
1213             cancel:false
1214         };
1215         if(this.fireEvent('beforequery', qe)===false || qe.cancel){
1216             return false;
1217         }
1218         q = qe.query;
1219         forceAll = qe.forceAll;
1220         if(forceAll === true || (q.length >= this.minChars)){
1221             if(this.lastQuery !== q){
1222                 this.lastQuery = q;
1223                 if(this.mode == 'local'){
1224                     this.selectedIndex = -1;
1225                     if(forceAll){
1226                         this.store.clearFilter();
1227                     }else{
1228                         this.store.filter(this.displayField, q);
1229                     }
1230                     this.onLoad();
1231                 }else{
1232                     this.store.baseParams[this.queryParam] = q;
1233                     this.store.load({
1234                         params: this.getParams(q)
1235                     });
1236                     this.expand();
1237                 }
1238             }else{
1239                 this.selectedIndex = -1;
1240                 this.onLoad();
1241             }
1242         }
1243     },
1244
1245     // private
1246     getParams : function(q){
1247         var p = {};
1248         //p[this.queryParam] = q;
1249         if(this.pageSize){
1250             p.start = 0;
1251             p.limit = this.pageSize;
1252         }
1253         return p;
1254     },
1255
1256     /**
1257      * Hides the dropdown list if it is currently expanded. Fires the {@link #collapse} event on completion.
1258      */
1259     collapse : function(){
1260         if(!this.isExpanded()){
1261             return;
1262         }
1263         this.list.hide();
1264         Ext.getDoc().un('mousewheel', this.collapseIf, this);
1265         Ext.getDoc().un('mousedown', this.collapseIf, this);
1266         this.fireEvent('collapse', this);
1267     },
1268
1269     // private
1270     collapseIf : function(e){
1271         if(!this.isDestroyed && !e.within(this.wrap) && !e.within(this.list)){
1272             this.collapse();
1273         }
1274     },
1275
1276     /**
1277      * Expands the dropdown list if it is currently hidden. Fires the {@link #expand} event on completion.
1278      */
1279     expand : function(){
1280         if(this.isExpanded() || !this.hasFocus){
1281             return;
1282         }
1283
1284         if(this.title || this.pageSize){
1285             this.assetHeight = 0;
1286             if(this.title){
1287                 this.assetHeight += this.header.getHeight();
1288             }
1289             if(this.pageSize){
1290                 this.assetHeight += this.footer.getHeight();
1291             }
1292         }
1293
1294         if(this.bufferSize){
1295             this.doResize(this.bufferSize);
1296             delete this.bufferSize;
1297         }
1298         this.list.alignTo.apply(this.list, [this.el].concat(this.listAlign));
1299
1300         // zindex can change, re-check it and set it if necessary
1301         var listParent = Ext.getDom(this.getListParent() || Ext.getBody()),
1302             zindex = parseInt(Ext.fly(listParent).getStyle('z-index') ,10);
1303         if (!zindex){
1304             zindex = this.getParentZIndex();
1305         }
1306         if (zindex) {
1307             this.list.setZIndex(zindex + 5);
1308         }
1309         this.list.show();
1310         if(Ext.isGecko2){
1311             this.innerList.setOverflow('auto'); // necessary for FF 2.0/Mac
1312         }
1313         this.mon(Ext.getDoc(), {
1314             scope: this,
1315             mousewheel: this.collapseIf,
1316             mousedown: this.collapseIf
1317         });
1318         this.fireEvent('expand', this);
1319     },
1320
1321     /**
1322      * @method onTriggerClick
1323      * @hide
1324      */
1325     // private
1326     // Implements the default empty TriggerField.onTriggerClick function
1327     onTriggerClick : function(){
1328         if(this.readOnly || this.disabled){
1329             return;
1330         }
1331         if(this.isExpanded()){
1332             this.collapse();
1333             this.el.focus();
1334         }else {
1335             this.onFocus({});
1336             if(this.triggerAction == 'all') {
1337                 this.doQuery(this.allQuery, true);
1338             } else {
1339                 this.doQuery(this.getRawValue());
1340             }
1341             this.el.focus();
1342         }
1343     }
1344
1345     /**
1346      * @hide
1347      * @method autoSize
1348      */
1349     /**
1350      * @cfg {Boolean} grow @hide
1351      */
1352     /**
1353      * @cfg {Number} growMin @hide
1354      */
1355     /**
1356      * @cfg {Number} growMax @hide
1357      */
1358
1359 });
1360 Ext.reg('combo', Ext.form.ComboBox);