3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js"><div id="cls-Ext.Component"></div>/**
10 * @class Ext.Component
11 * @extends Ext.util.Observable
12 * <p>Base class for all Ext components. All subclasses of Component may participate in the automated
13 * Ext component lifecycle of creation, rendering and destruction which is provided by the {@link Ext.Container Container} class.
14 * Components may be added to a Container through the {@link Ext.Container#items items} config option at the time the Container is created,
15 * or they may be added dynamically via the {@link Ext.Container#add add} method.</p>
16 * <p>The Component base class has built-in support for basic hide/show and enable/disable behavior.</p>
17 * <p>All Components are registered with the {@link Ext.ComponentMgr} on construction so that they can be referenced at any time via
18 * {@link Ext#getCmp}, passing the {@link #id}.</p>
19 * <p>All user-developed visual widgets that are required to participate in automated lifecycle and size management should subclass Component (or
20 * {@link Ext.BoxComponent} if managed box model handling is required, ie height and width management).</p>
21 * <p>See the <a href="http://extjs.com/learn/Tutorial:Creating_new_UI_controls">Creating new UI controls</a> tutorial for details on how
22 * and to either extend or augment ExtJs base classes to create custom Components.</p>
23 * <p>Every component has a specific xtype, which is its Ext-specific type name, along with methods for checking the
24 * xtype like {@link #getXType} and {@link #isXType}. This is the list of all valid xtypes:</p>
27 ------------- ------------------
28 box {@link Ext.BoxComponent}
29 button {@link Ext.Button}
30 buttongroup {@link Ext.ButtonGroup}
31 colorpalette {@link Ext.ColorPalette}
32 component {@link Ext.Component}
33 container {@link Ext.Container}
34 cycle {@link Ext.CycleButton}
35 dataview {@link Ext.DataView}
36 datepicker {@link Ext.DatePicker}
37 editor {@link Ext.Editor}
38 editorgrid {@link Ext.grid.EditorGridPanel}
39 flash {@link Ext.FlashComponent}
40 grid {@link Ext.grid.GridPanel}
41 listview {@link Ext.ListView}
42 panel {@link Ext.Panel}
43 progress {@link Ext.ProgressBar}
44 propertygrid {@link Ext.grid.PropertyGrid}
45 slider {@link Ext.Slider}
46 spacer {@link Ext.Spacer}
47 splitbutton {@link Ext.SplitButton}
48 tabpanel {@link Ext.TabPanel}
49 treepanel {@link Ext.tree.TreePanel}
50 viewport {@link Ext.ViewPort}
51 window {@link Ext.Window}
54 ---------------------------------------
55 paging {@link Ext.PagingToolbar}
56 toolbar {@link Ext.Toolbar}
57 tbbutton {@link Ext.Toolbar.Button} (deprecated; use button)
58 tbfill {@link Ext.Toolbar.Fill}
59 tbitem {@link Ext.Toolbar.Item}
60 tbseparator {@link Ext.Toolbar.Separator}
61 tbspacer {@link Ext.Toolbar.Spacer}
62 tbsplit {@link Ext.Toolbar.SplitButton} (deprecated; use splitbutton)
63 tbtext {@link Ext.Toolbar.TextItem}
66 ---------------------------------------
67 menu {@link Ext.menu.Menu}
68 colormenu {@link Ext.menu.ColorMenu}
69 datemenu {@link Ext.menu.DateMenu}
70 menubaseitem {@link Ext.menu.BaseItem}
71 menucheckitem {@link Ext.menu.CheckItem}
72 menuitem {@link Ext.menu.Item}
73 menuseparator {@link Ext.menu.Separator}
74 menutextitem {@link Ext.menu.TextItem}
77 ---------------------------------------
78 form {@link Ext.form.FormPanel}
79 checkbox {@link Ext.form.Checkbox}
80 checkboxgroup {@link Ext.form.CheckboxGroup}
81 combo {@link Ext.form.ComboBox}
82 datefield {@link Ext.form.DateField}
83 displayfield {@link Ext.form.DisplayField}
84 field {@link Ext.form.Field}
85 fieldset {@link Ext.form.FieldSet}
86 hidden {@link Ext.form.Hidden}
87 htmleditor {@link Ext.form.HtmlEditor}
88 label {@link Ext.form.Label}
89 numberfield {@link Ext.form.NumberField}
90 radio {@link Ext.form.Radio}
91 radiogroup {@link Ext.form.RadioGroup}
92 textarea {@link Ext.form.TextArea}
93 textfield {@link Ext.form.TextField}
94 timefield {@link Ext.form.TimeField}
95 trigger {@link Ext.form.TriggerField}
98 ---------------------------------------
99 chart {@link Ext.chart.Chart}
100 barchart {@link Ext.chart.BarChart}
101 cartesianchart {@link Ext.chart.CartesianChart}
102 columnchart {@link Ext.chart.ColumnChart}
103 linechart {@link Ext.chart.LineChart}
104 piechart {@link Ext.chart.PieChart}
107 ---------------------------------------
108 arraystore {@link Ext.data.ArrayStore}
109 directstore {@link Ext.data.DirectStore}
110 groupingstore {@link Ext.data.GroupingStore}
111 jsonstore {@link Ext.data.JsonStore}
112 simplestore {@link Ext.data.SimpleStore} (deprecated; use arraystore)
113 store {@link Ext.data.Store}
114 xmlstore {@link Ext.data.XmlStore}
117 * @param {Ext.Element/String/Object} config The configuration options may be specified as either:
118 * <div class="mdetail-params"><ul>
119 * <li><b>an element</b> :
120 * <p class="sub-desc">it is set as the internal element and its id used as the component id</p></li>
121 * <li><b>a string</b> :
122 * <p class="sub-desc">it is assumed to be the id of an existing element and is used as the component id</p></li>
123 * <li><b>anything else</b> :
124 * <p class="sub-desc">it is assumed to be a standard config object and is applied to the component</p></li>
127 Ext.Component = function(config){
128 config = config || {};
129 if(config.initialConfig){
130 if(config.isAction){ // actions
131 this.baseAction = config;
133 config = config.initialConfig; // component cloning / action set up
134 }else if(config.tagName || config.dom || Ext.isString(config)){ // element object
135 config = {applyTo: config, id: config.id || config};
138 <div id="prop-Ext.Component-initialConfig"></div>/**
139 * This Component's initial configuration specification. Read-only.
141 * @property initialConfig
143 this.initialConfig = config;
145 Ext.apply(this, config);
147 <div id="event-Ext.Component-added"></div>/**
149 * Fires when a component is added to an Ext.Container
150 * @param {Ext.Component} this
151 * @param {Ext.Container} ownerCt Container which holds the component
152 * @param {number} index Position at which the component was added
155 <div id="event-Ext.Component-disable"></div>/**
157 * Fires after the component is disabled.
158 * @param {Ext.Component} this
161 <div id="event-Ext.Component-enable"></div>/**
163 * Fires after the component is enabled.
164 * @param {Ext.Component} this
167 <div id="event-Ext.Component-beforeshow"></div>/**
169 * Fires before the component is shown by calling the {@link #show} method.
170 * Return false from an event handler to stop the show.
171 * @param {Ext.Component} this
174 <div id="event-Ext.Component-show"></div>/**
176 * Fires after the component is shown when calling the {@link #show} method.
177 * @param {Ext.Component} this
180 <div id="event-Ext.Component-beforehide"></div>/**
182 * Fires before the component is hidden by calling the {@link #hide} method.
183 * Return false from an event handler to stop the hide.
184 * @param {Ext.Component} this
187 <div id="event-Ext.Component-hide"></div>/**
189 * Fires after the component is hidden.
190 * Fires after the component is hidden when calling the {@link #hide} method.
191 * @param {Ext.Component} this
194 <div id="event-Ext.Component-removed"></div>/**
196 * Fires when a component is removed from an Ext.Container
197 * @param {Ext.Component} this
198 * @param {Ext.Container} ownerCt Container which holds the component
201 <div id="event-Ext.Component-beforerender"></div>/**
202 * @event beforerender
203 * Fires before the component is {@link #rendered}. Return false from an
204 * event handler to stop the {@link #render}.
205 * @param {Ext.Component} this
208 <div id="event-Ext.Component-render"></div>/**
210 * Fires after the component markup is {@link #rendered}.
211 * @param {Ext.Component} this
214 <div id="event-Ext.Component-afterrender"></div>/**
216 * <p>Fires after the component rendering is finished.</p>
217 * <p>The afterrender event is fired after this Component has been {@link #rendered}, been postprocesed
218 * by any afterRender method defined for the Component, and, if {@link #stateful}, after state
219 * has been restored.</p>
220 * @param {Ext.Component} this
223 <div id="event-Ext.Component-beforedestroy"></div>/**
224 * @event beforedestroy
225 * Fires before the component is {@link #destroy}ed. Return false from an event handler to stop the {@link #destroy}.
226 * @param {Ext.Component} this
229 <div id="event-Ext.Component-destroy"></div>/**
231 * Fires after the component is {@link #destroy}ed.
232 * @param {Ext.Component} this
235 <div id="event-Ext.Component-beforestaterestore"></div>/**
236 * @event beforestaterestore
237 * Fires before the state of the component is restored. Return false from an event handler to stop the restore.
238 * @param {Ext.Component} this
239 * @param {Object} state The hash of state values returned from the StateProvider. If this
240 * event is not vetoed, then the state object is passed to <b><tt>applyState</tt></b>. By default,
241 * that simply copies property values into this Component. The method maybe overriden to
242 * provide custom state restoration.
244 'beforestaterestore',
245 <div id="event-Ext.Component-staterestore"></div>/**
246 * @event staterestore
247 * Fires after the state of the component is restored.
248 * @param {Ext.Component} this
249 * @param {Object} state The hash of state values returned from the StateProvider. This is passed
250 * to <b><tt>applyState</tt></b>. By default, that simply copies property values into this
251 * Component. The method maybe overriden to provide custom state restoration.
254 <div id="event-Ext.Component-beforestatesave"></div>/**
255 * @event beforestatesave
256 * Fires before the state of the component is saved to the configured state provider. Return false to stop the save.
257 * @param {Ext.Component} this
258 * @param {Object} state The hash of state values. This is determined by calling
259 * <b><tt>getState()</tt></b> on the Component. This method must be provided by the
260 * developer to return whetever representation of state is required, by default, Ext.Component
261 * has a null implementation.
264 <div id="event-Ext.Component-statesave"></div>/**
266 * Fires after the state of the component is saved to the configured state provider.
267 * @param {Ext.Component} this
268 * @param {Object} state The hash of state values. This is determined by calling
269 * <b><tt>getState()</tt></b> on the Component. This method must be provided by the
270 * developer to return whetever representation of state is required, by default, Ext.Component
271 * has a null implementation.
276 Ext.ComponentMgr.register(this);
277 Ext.Component.superclass.constructor.call(this);
280 this.baseAction.addComponent(this);
283 this.initComponent();
286 if(Ext.isArray(this.plugins)){
287 for(var i = 0, len = this.plugins.length; i < len; i++){
288 this.plugins[i] = this.initPlugin(this.plugins[i]);
291 this.plugins = this.initPlugin(this.plugins);
295 if(this.stateful !== false){
300 this.applyToMarkup(this.applyTo);
302 }else if(this.renderTo){
303 this.render(this.renderTo);
304 delete this.renderTo;
309 Ext.Component.AUTO_ID = 1000;
311 Ext.extend(Ext.Component, Ext.util.Observable, {
312 // Configs below are used for all Components when rendered by FormLayout.
313 <div id="cfg-Ext.Component-fieldLabel"></div>/**
314 * @cfg {String} fieldLabel <p>The label text to display next to this Component (defaults to '').</p>
315 * <br><p><b>Note</b>: this config is only used when this Component is rendered by a Container which
316 * has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout manager (e.g.
317 * {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>).</p><br>
318 * <p>Also see <tt>{@link #hideLabel}</tt> and
319 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</p>
320 * Example use:<pre><code>
323 renderTo: Ext.getBody(),
331 <div id="cfg-Ext.Component-labelStyle"></div>/**
332 * @cfg {String} labelStyle <p>A CSS style specification string to apply directly to this field's
333 * label. Defaults to the container's labelStyle value if set (e.g.,
334 * <tt>{@link Ext.layout.FormLayout#labelStyle}</tt> , or '').</p>
335 * <br><p><b>Note</b>: see the note for <code>{@link #clearCls}</code>.</p><br>
336 * <p>Also see <code>{@link #hideLabel}</code> and
337 * <code>{@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</code></p>
338 * Example use:<pre><code>
341 renderTo: Ext.getBody(),
345 labelStyle: 'font-weight:bold;'
350 <div id="cfg-Ext.Component-labelSeparator"></div>/**
351 * @cfg {String} labelSeparator <p>The separator to display after the text of each
352 * <tt>{@link #fieldLabel}</tt>. This property may be configured at various levels.
353 * The order of precedence is:
354 * <div class="mdetail-params"><ul>
355 * <li>field / component level</li>
356 * <li>container level</li>
357 * <li>{@link Ext.layout.FormLayout#labelSeparator layout level} (defaults to colon <tt>':'</tt>)</li>
359 * To display no separator for this field's label specify empty string ''.</p>
360 * <br><p><b>Note</b>: see the note for <tt>{@link #clearCls}</tt>.</p><br>
361 * <p>Also see <tt>{@link #hideLabel}</tt> and
362 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}.</p>
363 * Example use:<pre><code>
366 renderTo: Ext.getBody(),
368 labelSeparator: '~' // layout config has lowest priority (defaults to ':')
370 {@link Ext.layout.FormLayout#labelSeparator labelSeparator}: '>>', // config at container level
373 fieldLabel: 'Field 1',
374 labelSeparator: '...' // field/component level config supersedes others
377 fieldLabel: 'Field 2' // labelSeparator will be '='
382 <div id="cfg-Ext.Component-hideLabel"></div>/**
383 * @cfg {Boolean} hideLabel <p><tt>true</tt> to completely hide the label element
384 * ({@link #fieldLabel label} and {@link #labelSeparator separator}). Defaults to <tt>false</tt>.
385 * By default, even if you do not specify a <tt>{@link #fieldLabel}</tt> the space will still be
386 * reserved so that the field will line up with other fields that do have labels.
387 * Setting this to <tt>true</tt> will cause the field to not reserve that space.</p>
388 * <br><p><b>Note</b>: see the note for <tt>{@link #clearCls}</tt>.</p><br>
389 * Example use:<pre><code>
392 renderTo: Ext.getBody(),
400 <div id="cfg-Ext.Component-clearCls"></div>/**
401 * @cfg {String} clearCls <p>The CSS class used to to apply to the special clearing div rendered
402 * directly after each form field wrapper to provide field clearing (defaults to
403 * <tt>'x-form-clear-left'</tt>).</p>
404 * <br><p><b>Note</b>: this config is only used when this Component is rendered by a Container
405 * which has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout
406 * manager (e.g. {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>) and either a
407 * <tt>{@link #fieldLabel}</tt> is specified or <tt>isFormField=true</tt> is specified.</p><br>
408 * <p>See {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl} also.</p>
410 <div id="cfg-Ext.Component-itemCls"></div>/**
411 * @cfg {String} itemCls
412 * <p><b>Note</b>: this config is only used when this Component is rendered by a Container which
413 * has been configured to use the <b>{@link Ext.layout.FormLayout FormLayout}</b> layout manager (e.g.
414 * {@link Ext.form.FormPanel} or specifying <tt>layout:'form'</tt>).</p><br>
415 * <p>An additional CSS class to apply to the div wrapping the form item
416 * element of this field. If supplied, <tt>itemCls</tt> at the <b>field</b> level will override
417 * the default <tt>itemCls</tt> supplied at the <b>container</b> level. The value specified for
418 * <tt>itemCls</tt> will be added to the default class (<tt>'x-form-item'</tt>).</p>
419 * <p>Since it is applied to the item wrapper (see
420 * {@link Ext.layout.FormLayout}.{@link Ext.layout.FormLayout#fieldTpl fieldTpl}), it allows
421 * you to write standard CSS rules that can apply to the field, the label (if specified), or
422 * any other element within the markup for the field.</p>
423 * <br><p><b>Note</b>: see the note for <tt>{@link #fieldLabel}</tt>.</p><br>
424 * Example use:<pre><code>
425 // Apply a style to the field's label:
427 .required .x-form-item-label {font-weight:bold;color:red;}
432 renderTo: Ext.getBody(),
436 itemCls: 'required' //this label will be styled
439 fieldLabel: 'Favorite Color'
445 <div id="cfg-Ext.Component-id"></div>/**
447 * <p>The <b>unique</b> id of this component (defaults to an {@link #getId auto-assigned id}).
448 * You should assign an id if you need to be able to access the component later and you do
449 * not have an object reference available (e.g., using {@link Ext}.{@link Ext#getCmp getCmp}).</p>
450 * <p>Note that this id will also be used as the element id for the containing HTML element
451 * that is rendered to the page for this component. This allows you to write id-based CSS
452 * rules to style the specific instance of this component uniquely, and also to select
453 * sub-elements using this component's id as the parent.</p>
454 * <p><b>Note</b>: to avoid complications imposed by a unique <tt>id</tt> also see
455 * <code>{@link #itemId}</code> and <code>{@link #ref}</code>.</p>
456 * <p><b>Note</b>: to access the container of an item see <code>{@link #ownerCt}</code>.</p>
458 <div id="cfg-Ext.Component-itemId"></div>/**
459 * @cfg {String} itemId
460 * <p>An <tt>itemId</tt> can be used as an alternative way to get a reference to a component
461 * when no object reference is available. Instead of using an <code>{@link #id}</code> with
462 * {@link Ext}.{@link Ext#getCmp getCmp}, use <code>itemId</code> with
463 * {@link Ext.Container}.{@link Ext.Container#getComponent getComponent} which will retrieve
464 * <code>itemId</code>'s or <tt>{@link #id}</tt>'s. Since <code>itemId</code>'s are an index to the
465 * container's internal MixedCollection, the <code>itemId</code> is scoped locally to the container --
466 * avoiding potential conflicts with {@link Ext.ComponentMgr} which requires a <b>unique</b>
467 * <code>{@link #id}</code>.</p>
469 var c = new Ext.Panel({ //
470 {@link Ext.BoxComponent#height height}: 300,
471 {@link #renderTo}: document.body,
472 {@link Ext.Container#layout layout}: 'auto',
473 {@link Ext.Container#items items}: [
476 {@link Ext.Panel#title title}: 'Panel 1',
477 {@link Ext.BoxComponent#height height}: 150
481 {@link Ext.Panel#title title}: 'Panel 2',
482 {@link Ext.BoxComponent#height height}: 150
486 p1 = c.{@link Ext.Container#getComponent getComponent}('p1'); // not the same as {@link Ext#getCmp Ext.getCmp()}
487 p2 = p1.{@link #ownerCt}.{@link Ext.Container#getComponent getComponent}('p2'); // reference via a sibling
489 * <p>Also see <tt>{@link #id}</tt> and <code>{@link #ref}</code>.</p>
490 * <p><b>Note</b>: to access the container of an item see <tt>{@link #ownerCt}</tt>.</p>
492 <div id="cfg-Ext.Component-xtype"></div>/**
493 * @cfg {String} xtype
494 * The registered <tt>xtype</tt> to create. This config option is not used when passing
495 * a config object into a constructor. This config option is used only when
496 * lazy instantiation is being used, and a child item of a Container is being
497 * specified not as a fully instantiated Component, but as a <i>Component config
498 * object</i>. The <tt>xtype</tt> will be looked up at render time up to determine what
499 * type of child Component to create.<br><br>
500 * The predefined xtypes are listed {@link Ext.Component here}.
502 * If you subclass Components to create your own Components, you may register
503 * them using {@link Ext.ComponentMgr#registerType} in order to be able to
504 * take advantage of lazy instantiation and rendering.
506 <div id="cfg-Ext.Component-ptype"></div>/**
507 * @cfg {String} ptype
508 * The registered <tt>ptype</tt> to create. This config option is not used when passing
509 * a config object into a constructor. This config option is used only when
510 * lazy instantiation is being used, and a Plugin is being
511 * specified not as a fully instantiated Component, but as a <i>Component config
512 * object</i>. The <tt>ptype</tt> will be looked up at render time up to determine what
513 * type of Plugin to create.<br><br>
514 * If you create your own Plugins, you may register them using
515 * {@link Ext.ComponentMgr#registerPlugin} in order to be able to
516 * take advantage of lazy instantiation and rendering.
518 <div id="cfg-Ext.Component-cls"></div>/**
520 * An optional extra CSS class that will be added to this component's Element (defaults to ''). This can be
521 * useful for adding customized styles to the component or any of its children using standard CSS rules.
523 <div id="cfg-Ext.Component-overCls"></div>/**
524 * @cfg {String} overCls
525 * An optional extra CSS class that will be added to this component's Element when the mouse moves
526 * over the Element, and removed when the mouse moves out. (defaults to ''). This can be
527 * useful for adding customized 'active' or 'hover' styles to the component or any of its children using standard CSS rules.
529 <div id="cfg-Ext.Component-style"></div>/**
530 * @cfg {String} style
531 * A custom style specification to be applied to this component's Element. Should be a valid argument to
532 * {@link Ext.Element#applyStyles}.
536 renderTo: Ext.getBody(),
537 width: 400, height: 300,
557 <div id="cfg-Ext.Component-ctCls"></div>/**
558 * @cfg {String} ctCls
559 * <p>An optional extra CSS class that will be added to this component's container. This can be useful for
560 * adding customized styles to the container or any of its children using standard CSS rules. See
561 * {@link Ext.layout.ContainerLayout}.{@link Ext.layout.ContainerLayout#extraCls extraCls} also.</p>
562 * <p><b>Note</b>: <tt>ctCls</tt> defaults to <tt>''</tt> except for the following class
563 * which assigns a value by default:
564 * <div class="mdetail-params"><ul>
565 * <li>{@link Ext.layout.Box Box Layout} : <tt>'x-box-layout-ct'</tt></li>
567 * To configure the above Class with an extra CSS class append to the default. For example,
568 * for BoxLayout (Hbox and Vbox):<pre><code>
569 * ctCls: 'x-box-layout-ct custom-class'
573 <div id="cfg-Ext.Component-disabled"></div>/**
574 * @cfg {Boolean} disabled
575 * Render this component disabled (default is false).
578 <div id="cfg-Ext.Component-hidden"></div>/**
579 * @cfg {Boolean} hidden
580 * Render this component hidden (default is false). If <tt>true</tt>, the
581 * {@link #hide} method will be called internally.
584 <div id="cfg-Ext.Component-plugins"></div>/**
585 * @cfg {Object/Array} plugins
586 * An object or array of objects that will provide custom functionality for this component. The only
587 * requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component.
588 * When a component is created, if any plugins are available, the component will call the init method on each
589 * plugin, passing a reference to itself. Each plugin can then call methods or respond to events on the
590 * component as needed to provide its functionality.
592 <div id="cfg-Ext.Component-applyTo"></div>/**
593 * @cfg {Mixed} applyTo
594 * <p>Specify the id of the element, a DOM element or an existing Element corresponding to a DIV
595 * that is already present in the document that specifies some structural markup for this
596 * component.</p><div><ul>
597 * <li><b>Description</b> : <ul>
598 * <div class="sub-desc">When <tt>applyTo</tt> is used, constituent parts of the component can also be specified
599 * by id or CSS class name within the main element, and the component being created may attempt
600 * to create its subcomponents from that markup if applicable.</div>
602 * <li><b>Notes</b> : <ul>
603 * <div class="sub-desc">When using this config, a call to render() is not required.</div>
604 * <div class="sub-desc">If applyTo is specified, any value passed for {@link #renderTo} will be ignored and the target
605 * element's parent node will automatically be used as the component's container.</div>
609 <div id="cfg-Ext.Component-renderTo"></div>/**
610 * @cfg {Mixed} renderTo
611 * <p>Specify the id of the element, a DOM element or an existing Element that this component
612 * will be rendered into.</p><div><ul>
613 * <li><b>Notes</b> : <ul>
614 * <div class="sub-desc">Do <u>not</u> use this option if the Component is to be a child item of
615 * a {@link Ext.Container Container}. It is the responsibility of the
616 * {@link Ext.Container Container}'s {@link Ext.Container#layout layout manager}
617 * to render and manage its child items.</div>
618 * <div class="sub-desc">When using this config, a call to render() is not required.</div>
621 * <p>See <tt>{@link #render}</tt> also.</p>
623 <div id="cfg-Ext.Component-stateful"></div>/**
624 * @cfg {Boolean} stateful
625 * <p>A flag which causes the Component to attempt to restore the state of
626 * internal properties from a saved state on startup. The component must have
627 * either a <code>{@link #stateId}</code> or <code>{@link #id}</code> assigned
628 * for state to be managed. Auto-generated ids are not guaranteed to be stable
629 * across page loads and cannot be relied upon to save and restore the same
630 * state for a component.<p>
631 * <p>For state saving to work, the state manager's provider must have been
632 * set to an implementation of {@link Ext.state.Provider} which overrides the
633 * {@link Ext.state.Provider#set set} and {@link Ext.state.Provider#get get}
634 * methods to save and recall name/value pairs. A built-in implementation,
635 * {@link Ext.state.CookieProvider} is available.</p>
636 * <p>To set the state provider for the current page:</p>
638 Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
639 expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now
642 * <p>A stateful Component attempts to save state when one of the events
643 * listed in the <code>{@link #stateEvents}</code> configuration fires.</p>
644 * <p>To save state, a stateful Component first serializes its state by
645 * calling <b><code>getState</code></b>. By default, this function does
646 * nothing. The developer must provide an implementation which returns an
647 * object hash which represents the Component's restorable state.</p>
648 * <p>The value yielded by getState is passed to {@link Ext.state.Manager#set}
649 * which uses the configured {@link Ext.state.Provider} to save the object
650 * keyed by the Component's <code>{@link stateId}</code>, or, if that is not
651 * specified, its <code>{@link #id}</code>.</p>
652 * <p>During construction, a stateful Component attempts to <i>restore</i>
653 * its state by calling {@link Ext.state.Manager#get} passing the
654 * <code>{@link #stateId}</code>, or, if that is not specified, the
655 * <code>{@link #id}</code>.</p>
656 * <p>The resulting object is passed to <b><code>applyState</code></b>.
657 * The default implementation of <code>applyState</code> simply copies
658 * properties into the object, but a developer may override this to support
659 * more behaviour.</p>
660 * <p>You can perform extra processing on state save and restore by attaching
661 * handlers to the {@link #beforestaterestore}, {@link #staterestore},
662 * {@link #beforestatesave} and {@link #statesave} events.</p>
664 <div id="cfg-Ext.Component-stateId"></div>/**
665 * @cfg {String} stateId
666 * The unique id for this component to use for state management purposes
667 * (defaults to the component id if one was set, otherwise null if the
668 * component is using a generated id).
669 * <p>See <code>{@link #stateful}</code> for an explanation of saving and
670 * restoring Component state.</p>
672 <div id="cfg-Ext.Component-stateEvents"></div>/**
673 * @cfg {Array} stateEvents
674 * <p>An array of events that, when fired, should trigger this component to
675 * save its state (defaults to none). <code>stateEvents</code> may be any type
676 * of event supported by this component, including browser or custom events
677 * (e.g., <tt>['click', 'customerchange']</tt>).</p>
678 * <p>See <code>{@link #stateful}</code> for an explanation of saving and
679 * restoring Component state.</p>
681 <div id="cfg-Ext.Component-autoEl"></div>/**
682 * @cfg {Mixed} autoEl
683 * <p>A tag name or {@link Ext.DomHelper DomHelper} spec used to create the {@link #getEl Element} which will
684 * encapsulate this Component.</p>
685 * <p>You do not normally need to specify this. For the base classes {@link Ext.Component}, {@link Ext.BoxComponent},
686 * and {@link Ext.Container}, this defaults to <b><tt>'div'</tt></b>. The more complex Ext classes use a more complex
687 * DOM structure created by their own onRender methods.</p>
688 * <p>This is intended to allow the developer to create application-specific utility Components encapsulated by
689 * different DOM elements. Example usage:</p><pre><code>
694 src: 'http://www.example.com/example.jpg'
700 html: 'autoEl is cool!'
705 cls: 'ux-unordered-list',
709 html: 'First list item'
716 <div id="cfg-Ext.Component-disabledClass"></div>/**
717 * @cfg {String} disabledClass
718 * CSS class added to the component when it is disabled (defaults to 'x-item-disabled').
720 disabledClass : 'x-item-disabled',
721 <div id="cfg-Ext.Component-allowDomMove"></div>/**
722 * @cfg {Boolean} allowDomMove
723 * Whether the component can move the Dom node when rendering (defaults to true).
726 <div id="cfg-Ext.Component-autoShow"></div>/**
727 * @cfg {Boolean} autoShow
728 * True if the component should check for hidden classes (e.g. 'x-hidden' or 'x-hide-display') and remove
729 * them on render (defaults to false).
732 <div id="cfg-Ext.Component-hideMode"></div>/**
733 * @cfg {String} hideMode
734 * <p>How this component should be hidden. Supported values are <tt>'visibility'</tt>
735 * (css visibility), <tt>'offsets'</tt> (negative offset position) and <tt>'display'</tt>
737 * <br><p><b>Note</b>: the default of <tt>'display'</tt> is generally preferred
738 * since items are automatically laid out when they are first shown (no sizing
739 * is done while hidden).</p>
741 hideMode : 'display',
742 <div id="cfg-Ext.Component-hideParent"></div>/**
743 * @cfg {Boolean} hideParent
744 * True to hide and show the component's container when hide/show is called on the component, false to hide
745 * and show the component itself (defaults to false). For example, this can be used as a shortcut for a hide
746 * button on a window by setting hide:true on the button when adding it to its parent container.
749 <div id="prop-Ext.Component-el"></div>/**
750 * <p>The {@link Ext.Element} which encapsulates this Component. Read-only.</p>
751 * <p>This will <i>usually</i> be a <DIV> element created by the class's onRender method, but
752 * that may be overridden using the <code>{@link #autoEl}</code> config.</p>
753 * <br><p><b>Note</b>: this element will not be available until this Component has been rendered.</p><br>
754 * <p>To add listeners for <b>DOM events</b> to this Component (as opposed to listeners
755 * for this Component's own Observable events), see the {@link Ext.util.Observable#listeners listeners}
756 * config for a suggestion, or use a render listener directly:</p><pre><code>
758 title: 'The Clickable Panel',
760 render: function(p) {
761 // Append the Panel to the click handler's argument list.
762 p.getEl().on('click', handlePanelClick.createDelegate(null, [p], true));
764 single: true // Remove the listener after first invocation
768 * <p>See also <tt>{@link #getEl getEl}</p>
772 <div id="prop-Ext.Component-ownerCt"></div>/**
773 * This Component's owner {@link Ext.Container Container} (defaults to undefined, and is set automatically when
774 * this Component is added to a Container). Read-only.
775 * <p><b>Note</b>: to access items within the Container see <tt>{@link #itemId}</tt>.</p>
776 * @type Ext.Container
779 <div id="prop-Ext.Component-hidden"></div>/**
780 * True if this component is hidden. Read-only.
784 <div id="prop-Ext.Component-disabled"></div>/**
785 * True if this component is disabled. Read-only.
789 <div id="prop-Ext.Component-rendered"></div>/**
790 * True if this component has been rendered. Read-only.
796 <div id="cfg-Ext.Component-contentEl"></div>/**
797 * @cfg {String} contentEl
798 * <p>Optional. Specify an existing HTML element, or the <code>id</code> of an existing HTML element to use as the content
799 * for this component.</p>
801 * <li><b>Description</b> :
802 * <div class="sub-desc">This config option is used to take an existing HTML element and place it in the layout element
803 * of a new component (it simply moves the specified DOM element <i>after the Component is rendered</i> to use as the content.</div></li>
805 * <div class="sub-desc">The specified HTML element is appended to the layout element of the component <i>after any configured
806 * {@link #html HTML} has been inserted</i>, and so the document will not contain this element at the time the {@link #render} event is fired.</div>
807 * <div class="sub-desc">The specified HTML element used will not participate in any <code><b>{@link Ext.Container#layout layout}</b></code>
808 * scheme that the Component may use. It is just HTML. Layouts operate on child <code><b>{@link Ext.Container#items items}</b></code>.</div>
809 * <div class="sub-desc">Add either the <code>x-hidden</code> or the <code>x-hide-display</code> CSS class to
810 * prevent a brief flicker of the content before it is rendered to the panel.</div></li>
813 <div id="cfg-Ext.Component-html"></div>/**
814 * @cfg {String/Object} html
815 * An HTML fragment, or a {@link Ext.DomHelper DomHelper} specification to use as the layout element
816 * content (defaults to ''). The HTML content is added after the component is rendered,
817 * so the document will not contain this HTML at the time the {@link #render} event is fired.
818 * This content is inserted into the body <i>before</i> any configured {@link #contentEl} is appended.
821 <div id="cfg-Ext.Component-tpl"></div>/**
823 * An <bold>{@link Ext.Template}</bold>, <bold>{@link Ext.XTemplate}</bold>
824 * or an array of strings to form an Ext.XTemplate.
825 * Used in conjunction with the <code>{@link #data}</code> and
826 * <code>{@link #tplWriteMode}</code> configurations.
829 <div id="cfg-Ext.Component-tplWriteMode"></div>/**
830 * @cfg {String} tplWriteMode The Ext.(X)Template method to use when
831 * updating the content area of the Component. Defaults to <tt>'overwrite'</tt>
832 * (see <code>{@link Ext.XTemplate#overwrite}</code>).
834 tplWriteMode : 'overwrite',
836 <div id="cfg-Ext.Component-data"></div>/**
838 * The initial set of data to apply to the <code>{@link #tpl}</code> to
839 * update the content area of the Component.
844 ctype : 'Ext.Component',
850 getActionEl : function(){
851 return this[this.actionMode];
854 initPlugin : function(p){
855 if(p.ptype && !Ext.isFunction(p.init)){
856 p = Ext.ComponentMgr.createPlugin(p);
857 }else if(Ext.isString(p)){
858 p = Ext.ComponentMgr.createPlugin({
867 * Function to be implemented by Component subclasses to be part of standard component initialization flow (it is empty by default).
869 // Traditional constructor:
870 Ext.Foo = function(config){
871 // call superclass constructor:
872 Ext.Foo.superclass.constructor.call(this, config);
878 Ext.extend(Ext.Foo, Ext.Bar, {
882 // initComponent replaces the constructor:
883 Ext.Foo = Ext.extend(Ext.Bar, {
884 initComponent : function(){
885 // call superclass initComponent
886 Ext.Container.superclass.initComponent.call(this);
895 initComponent : Ext.emptyFn,
897 <div id="method-Ext.Component-render"></div>/**
898 * <p>Render this Component into the passed HTML element.</p>
899 * <p><b>If you are using a {@link Ext.Container Container} object to house this Component, then
900 * do not use the render method.</b></p>
901 * <p>A Container's child Components are rendered by that Container's
902 * {@link Ext.Container#layout layout} manager when the Container is first rendered.</p>
903 * <p>Certain layout managers allow dynamic addition of child components. Those that do
904 * include {@link Ext.layout.CardLayout}, {@link Ext.layout.AnchorLayout},
905 * {@link Ext.layout.FormLayout}, {@link Ext.layout.TableLayout}.</p>
906 * <p>If the Container is already rendered when a new child Component is added, you may need to call
907 * the Container's {@link Ext.Container#doLayout doLayout} to refresh the view which causes any
908 * unrendered child Components to be rendered. This is required so that you can add multiple
909 * child components if needed while only refreshing the layout once.</p>
910 * <p>When creating complex UIs, it is important to remember that sizing and positioning
911 * of child items is the responsibility of the Container's {@link Ext.Container#layout layout} manager.
912 * If you expect child items to be sized in response to user interactions, you must
913 * configure the Container with a layout manager which creates and manages the type of layout you
915 * <p><b>Omitting the Container's {@link Ext.Container#layout layout} config means that a basic
916 * layout manager is used which does nothing but render child components sequentially into the
917 * Container. No sizing or positioning will be performed in this situation.</b></p>
918 * @param {Element/HTMLElement/String} container (optional) The element this Component should be
919 * rendered into. If it is being created from existing markup, this should be omitted.
920 * @param {String/Number} position (optional) The element ID or DOM node index within the container <b>before</b>
921 * which this component will be inserted (defaults to appending to the end of the container)
923 render : function(container, position){
924 if(!this.rendered && this.fireEvent('beforerender', this) !== false){
925 if(!container && this.el){
926 this.el = Ext.get(this.el);
927 container = this.el.dom.parentNode;
928 this.allowDomMove = false;
930 this.container = Ext.get(container);
932 this.container.addClass(this.ctCls);
934 this.rendered = true;
935 if(position !== undefined){
936 if(Ext.isNumber(position)){
937 position = this.container.dom.childNodes[position];
939 position = Ext.getDom(position);
942 this.onRender(this.container, position || null);
944 this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
947 this.el.addClass(this.cls);
951 this.el.applyStyles(this.style);
955 this.el.addClassOnOver(this.overCls);
957 this.fireEvent('render', this);
960 // Populate content of the component with html, contentEl or
962 var contentTarget = this.getContentTarget();
964 contentTarget.update(Ext.DomHelper.markup(this.html));
968 var ce = Ext.getDom(this.contentEl);
969 Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
970 contentTarget.appendChild(ce);
973 if (!this.tpl.compile) {
974 this.tpl = new Ext.XTemplate(this.tpl);
977 this.tpl[this.tplWriteMode](contentTarget, this.data);
981 this.afterRender(this.container);
985 // call this so we don't fire initial hide events.
989 // pass silent so the event doesn't fire the first time.
993 if(this.stateful !== false){
994 this.initStateEvents();
996 this.fireEvent('afterrender', this);
1002 <div id="method-Ext.Component-update"></div>/**
1003 * Update the content area of a component.
1004 * @param {Mixed} htmlOrData
1005 * If this component has been configured with a template via the tpl config
1006 * then it will use this argument as data to populate the template.
1007 * If this component was not configured with a template, the components
1008 * content area will be updated via Ext.Element update
1009 * @param {Boolean} loadScripts
1010 * (optional) Only legitimate when using the html configuration. Defaults to false
1011 * @param {Function} callback
1012 * (optional) Only legitimate when using the html configuration. Callback to execute when scripts have finished loading
1014 update: function(htmlOrData, loadScripts, cb) {
1015 var contentTarget = this.getContentTarget();
1016 if (this.tpl && typeof htmlOrData !== "string") {
1017 this.tpl[this.tplWriteMode](contentTarget, htmlOrData || {});
1019 var html = Ext.isObject(htmlOrData) ? Ext.DomHelper.markup(htmlOrData) : htmlOrData;
1020 contentTarget.update(html, loadScripts, cb);
1027 * Method to manage awareness of when components are added to their
1028 * respective Container, firing an added event.
1029 * References are established at add time rather than at render time.
1030 * @param {Ext.Container} container Container which holds the component
1031 * @param {number} pos Position at which the component was added
1033 onAdded : function(container, pos) {
1034 this.ownerCt = container;
1036 this.fireEvent('added', this, container, pos);
1041 * Method to manage awareness of when components are removed from their
1042 * respective Container, firing an removed event. References are properly
1043 * cleaned up after removing a component from its owning container.
1045 onRemoved : function() {
1047 this.fireEvent('removed', this, this.ownerCt);
1048 delete this.ownerCt;
1053 * Method to establish a reference to a component.
1055 initRef : function() {
1056 <div id="cfg-Ext.Component-ref"></div>/**
1058 * <p>A path specification, relative to the Component's <code>{@link #ownerCt}</code>
1059 * specifying into which ancestor Container to place a named reference to this Component.</p>
1060 * <p>The ancestor axis can be traversed by using '/' characters in the path.
1061 * For example, to put a reference to a Toolbar Button into <i>the Panel which owns the Toolbar</i>:</p><pre><code>
1062 var myGrid = new Ext.grid.EditorGridPanel({
1063 title: 'My EditorGridPanel',
1065 colModel: myColModel,
1068 handler: saveChanges,
1070 ref: '../saveButton'
1073 afteredit: function() {
1074 // The button reference is in the GridPanel
1075 myGrid.saveButton.enable();
1080 * <p>In the code above, if the <code>ref</code> had been <code>'saveButton'</code>
1081 * the reference would have been placed into the Toolbar. Each '/' in the <code>ref</code>
1082 * moves up one level from the Component's <code>{@link #ownerCt}</code>.</p>
1083 * <p>Also see the <code>{@link #added}</code> and <code>{@link #removed}</code> events.</p>
1085 if(this.ref && !this.refOwner){
1086 var levels = this.ref.split('/'),
1087 last = levels.length,
1091 while(t && i < last){
1096 t[this.refName = levels[--i]] = this;
1097 <div id="prop-Ext.Component-refOwner"></div>/**
1098 * @type Ext.Container
1099 * @property refOwner
1100 * The ancestor Container into which the {@link #ref} reference was inserted if this Component
1101 * is a child of a Container, and has been configured with a <code>ref</code>.
1108 removeRef : function() {
1109 if (this.refOwner && this.refName) {
1110 delete this.refOwner[this.refName];
1111 delete this.refOwner;
1116 initState : function(){
1117 if(Ext.state.Manager){
1118 var id = this.getStateId();
1120 var state = Ext.state.Manager.get(id);
1122 if(this.fireEvent('beforestaterestore', this, state) !== false){
1123 this.applyState(Ext.apply({}, state));
1124 this.fireEvent('staterestore', this, state);
1132 getStateId : function(){
1133 return this.stateId || ((/^(ext-comp-|ext-gen)/).test(String(this.id)) ? null : this.id);
1137 initStateEvents : function(){
1138 if(this.stateEvents){
1139 for(var i = 0, e; e = this.stateEvents[i]; i++){
1140 this.on(e, this.saveState, this, {delay:100});
1146 applyState : function(state){
1148 Ext.apply(this, state);
1153 getState : function(){
1158 saveState : function(){
1159 if(Ext.state.Manager && this.stateful !== false){
1160 var id = this.getStateId();
1162 var state = this.getState();
1163 if(this.fireEvent('beforestatesave', this, state) !== false){
1164 Ext.state.Manager.set(id, state);
1165 this.fireEvent('statesave', this, state);
1171 <div id="method-Ext.Component-applyToMarkup"></div>/**
1172 * Apply this component to existing markup that is valid. With this function, no call to render() is required.
1173 * @param {String/HTMLElement} el
1175 applyToMarkup : function(el){
1176 this.allowDomMove = false;
1177 this.el = Ext.get(el);
1178 this.render(this.el.dom.parentNode);
1181 <div id="method-Ext.Component-addClass"></div>/**
1182 * Adds a CSS class to the component's underlying element.
1183 * @param {string} cls The CSS class name to add
1184 * @return {Ext.Component} this
1186 addClass : function(cls){
1188 this.el.addClass(cls);
1190 this.cls = this.cls ? this.cls + ' ' + cls : cls;
1195 <div id="method-Ext.Component-removeClass"></div>/**
1196 * Removes a CSS class from the component's underlying element.
1197 * @param {string} cls The CSS class name to remove
1198 * @return {Ext.Component} this
1200 removeClass : function(cls){
1202 this.el.removeClass(cls);
1204 this.cls = this.cls.split(' ').remove(cls).join(' ');
1210 // default function is not really useful
1211 onRender : function(ct, position){
1212 if(!this.el && this.autoEl){
1213 if(Ext.isString(this.autoEl)){
1214 this.el = document.createElement(this.autoEl);
1216 var div = document.createElement('div');
1217 Ext.DomHelper.overwrite(div, this.autoEl);
1218 this.el = div.firstChild;
1221 this.el.id = this.getId();
1225 this.el = Ext.get(this.el);
1226 if(this.allowDomMove !== false){
1227 ct.dom.insertBefore(this.el.dom, position);
1229 Ext.removeNode(div);
1237 getAutoCreate : function(){
1238 var cfg = Ext.isObject(this.autoCreate) ?
1239 this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
1240 if(this.id && !cfg.id){
1247 afterRender : Ext.emptyFn,
1249 <div id="method-Ext.Component-destroy"></div>/**
1250 * Destroys this component by purging any event listeners, removing the component's element from the DOM,
1251 * removing the component from its {@link Ext.Container} (if applicable) and unregistering it from
1252 * {@link Ext.ComponentMgr}. Destruction is generally handled automatically by the framework and this method
1253 * should usually not need to be called directly.
1256 destroy : function(){
1257 if(!this.isDestroyed){
1258 if(this.fireEvent('beforedestroy', this) !== false){
1259 this.destroying = true;
1260 this.beforeDestroy();
1261 if(this.ownerCt && this.ownerCt.remove){
1262 this.ownerCt.remove(this, false);
1266 if(this.actionMode == 'container' || this.removeMode == 'container'){
1267 this.container.remove();
1271 Ext.ComponentMgr.unregister(this);
1272 this.fireEvent('destroy', this);
1273 this.purgeListeners();
1274 this.destroying = false;
1275 this.isDestroyed = true;
1280 deleteMembers : function(){
1281 var args = arguments;
1282 for(var i = 0, len = args.length; i < len; ++i){
1283 delete this[args[i]];
1288 beforeDestroy : Ext.emptyFn,
1291 onDestroy : Ext.emptyFn,
1293 <div id="method-Ext.Component-getEl"></div>/**
1294 * <p>Returns the {@link Ext.Element} which encapsulates this Component.</p>
1295 * <p>This will <i>usually</i> be a <DIV> element created by the class's onRender method, but
1296 * that may be overridden using the {@link #autoEl} config.</p>
1297 * <br><p><b>Note</b>: this element will not be available until this Component has been rendered.</p><br>
1298 * <p>To add listeners for <b>DOM events</b> to this Component (as opposed to listeners
1299 * for this Component's own Observable events), see the {@link #listeners} config for a suggestion,
1300 * or use a render listener directly:</p><pre><code>
1302 title: 'The Clickable Panel',
1304 render: function(p) {
1305 // Append the Panel to the click handler's argument list.
1306 p.getEl().on('click', handlePanelClick.createDelegate(null, [p], true));
1308 single: true // Remove the listener after first invocation
1312 * @return {Ext.Element} The Element which encapsulates this Component.
1319 getContentTarget : function(){
1323 <div id="method-Ext.Component-getId"></div>/**
1324 * Returns the <code>id</code> of this component or automatically generates and
1325 * returns an <code>id</code> if an <code>id</code> is not defined yet:<pre><code>
1326 * 'ext-comp-' + (++Ext.Component.AUTO_ID)
1328 * @return {String} id
1331 return this.id || (this.id = 'ext-comp-' + (++Ext.Component.AUTO_ID));
1334 <div id="method-Ext.Component-getItemId"></div>/**
1335 * Returns the <code>{@link #itemId}</code> of this component. If an
1336 * <code>{@link #itemId}</code> was not assigned through configuration the
1337 * <code>id</code> is returned using <code>{@link #getId}</code>.
1340 getItemId : function(){
1341 return this.itemId || this.getId();
1344 <div id="method-Ext.Component-focus"></div>/**
1345 * Try to focus this component.
1346 * @param {Boolean} selectText (optional) If applicable, true to also select the text in this component
1347 * @param {Boolean/Number} delay (optional) Delay the focus this number of milliseconds (true for 10 milliseconds)
1348 * @return {Ext.Component} this
1350 focus : function(selectText, delay){
1352 this.focus.defer(Ext.isNumber(delay) ? delay : 10, this, [selectText, false]);
1357 if(selectText === true){
1358 this.el.dom.select();
1372 <div id="method-Ext.Component-disable"></div>/**
1373 * Disable this component and fire the 'disable' event.
1374 * @return {Ext.Component} this
1376 disable : function(/* private */ silent){
1380 this.disabled = true;
1381 if(silent !== true){
1382 this.fireEvent('disable', this);
1388 onDisable : function(){
1389 this.getActionEl().addClass(this.disabledClass);
1390 this.el.dom.disabled = true;
1393 <div id="method-Ext.Component-enable"></div>/**
1394 * Enable this component and fire the 'enable' event.
1395 * @return {Ext.Component} this
1397 enable : function(){
1401 this.disabled = false;
1402 this.fireEvent('enable', this);
1407 onEnable : function(){
1408 this.getActionEl().removeClass(this.disabledClass);
1409 this.el.dom.disabled = false;
1412 <div id="method-Ext.Component-setDisabled"></div>/**
1413 * Convenience function for setting disabled/enabled by boolean.
1414 * @param {Boolean} disabled
1415 * @return {Ext.Component} this
1417 setDisabled : function(disabled){
1418 return this[disabled ? 'disable' : 'enable']();
1421 <div id="method-Ext.Component-show"></div>/**
1422 * Show this component. Listen to the '{@link #beforeshow}' event and return
1423 * <tt>false</tt> to cancel showing the component. Fires the '{@link #show}'
1424 * event after showing the component.
1425 * @return {Ext.Component} this
1428 if(this.fireEvent('beforeshow', this) !== false){
1429 this.hidden = false;
1430 if(this.autoRender){
1431 this.render(Ext.isBoolean(this.autoRender) ? Ext.getBody() : this.autoRender);
1436 this.fireEvent('show', this);
1442 onShow : function(){
1443 this.getVisibilityEl().removeClass('x-hide-' + this.hideMode);
1446 <div id="method-Ext.Component-hide"></div>/**
1447 * Hide this component. Listen to the '{@link #beforehide}' event and return
1448 * <tt>false</tt> to cancel hiding the component. Fires the '{@link #hide}'
1449 * event after hiding the component. Note this method is called internally if
1450 * the component is configured to be <code>{@link #hidden}</code>.
1451 * @return {Ext.Component} this
1454 if(this.fireEvent('beforehide', this) !== false){
1456 this.fireEvent('hide', this);
1470 onHide : function(){
1471 this.getVisibilityEl().addClass('x-hide-' + this.hideMode);
1475 getVisibilityEl : function(){
1476 return this.hideParent ? this.container : this.getActionEl();
1479 <div id="method-Ext.Component-setVisible"></div>/**
1480 * Convenience function to hide or show this component by boolean.
1481 * @param {Boolean} visible True to show, false to hide
1482 * @return {Ext.Component} this
1484 setVisible : function(visible){
1485 return this[visible ? 'show' : 'hide']();
1488 <div id="method-Ext.Component-isVisible"></div>/**
1489 * Returns true if this component is visible.
1490 * @return {Boolean} True if this component is visible, false otherwise.
1492 isVisible : function(){
1493 return this.rendered && this.getVisibilityEl().isVisible();
1496 <div id="method-Ext.Component-cloneConfig"></div>/**
1497 * Clone the current component using the original config values passed into this instance by default.
1498 * @param {Object} overrides A new config containing any properties to override in the cloned version.
1499 * An id property can be passed on this object, otherwise one will be generated to avoid duplicates.
1500 * @return {Ext.Component} clone The cloned copy of this component
1502 cloneConfig : function(overrides){
1503 overrides = overrides || {};
1504 var id = overrides.id || Ext.id();
1505 var cfg = Ext.applyIf(overrides, this.initialConfig);
1506 cfg.id = id; // prevent dup id
1507 return new this.constructor(cfg);
1510 <div id="method-Ext.Component-getXType"></div>/**
1511 * Gets the xtype for this component as registered with {@link Ext.ComponentMgr}. For a list of all
1512 * available xtypes, see the {@link Ext.Component} header. Example usage:
1514 var t = new Ext.form.TextField();
1515 alert(t.getXType()); // alerts 'textfield'
1517 * @return {String} The xtype
1519 getXType : function(){
1520 return this.constructor.xtype;
1523 <div id="method-Ext.Component-isXType"></div>/**
1524 * <p>Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended
1525 * from the xtype (default) or whether it is directly of the xtype specified (shallow = true).</p>
1526 * <p><b>If using your own subclasses, be aware that a Component must register its own xtype
1527 * to participate in determination of inherited xtypes.</b></p>
1528 * <p>For a list of all available xtypes, see the {@link Ext.Component} header.</p>
1529 * <p>Example usage:</p>
1531 var t = new Ext.form.TextField();
1532 var isText = t.isXType('textfield'); // true
1533 var isBoxSubclass = t.isXType('box'); // true, descended from BoxComponent
1534 var isBoxInstance = t.isXType('box', true); // false, not a direct BoxComponent instance
1536 * @param {String} xtype The xtype to check for this Component
1537 * @param {Boolean} shallow (optional) False to check whether this Component is descended from the xtype (this is
1538 * the default), or true to check whether this Component is directly of the specified xtype.
1539 * @return {Boolean} True if this component descends from the specified xtype, false otherwise.
1541 isXType : function(xtype, shallow){
1542 //assume a string by default
1543 if (Ext.isFunction(xtype)){
1544 xtype = xtype.xtype; //handle being passed the class, e.g. Ext.Component
1545 }else if (Ext.isObject(xtype)){
1546 xtype = xtype.constructor.xtype; //handle being passed an instance
1549 return !shallow ? ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 : this.constructor.xtype == xtype;
1552 <div id="method-Ext.Component-getXTypes"></div>/**
1553 * <p>Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all
1554 * available xtypes, see the {@link Ext.Component} header.</p>
1555 * <p><b>If using your own subclasses, be aware that a Component must register its own xtype
1556 * to participate in determination of inherited xtypes.</b></p>
1557 * <p>Example usage:</p>
1559 var t = new Ext.form.TextField();
1560 alert(t.getXTypes()); // alerts 'component/box/field/textfield'
1562 * @return {String} The xtype hierarchy string
1564 getXTypes : function(){
1565 var tc = this.constructor;
1567 var c = [], sc = this;
1568 while(sc && sc.constructor.xtype){
1569 c.unshift(sc.constructor.xtype);
1570 sc = sc.constructor.superclass;
1573 tc.xtypes = c.join('/');
1578 <div id="method-Ext.Component-findParentBy"></div>/**
1579 * Find a container above this component at any level by a custom function. If the passed function returns
1580 * true, the container will be returned.
1581 * @param {Function} fn The custom function to call with the arguments (container, this component).
1582 * @return {Ext.Container} The first Container for which the custom function returns true
1584 findParentBy : function(fn) {
1585 for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
1589 <div id="method-Ext.Component-findParentByType"></div>/**
1590 * Find a container above this component at any level by xtype or class
1591 * @param {String/Class} xtype The xtype string for a component, or the class of the component directly
1592 * @return {Ext.Container} The first Container which matches the given xtype or class
1594 findParentByType : function(xtype) {
1595 return Ext.isFunction(xtype) ?
1596 this.findParentBy(function(p){
1597 return p.constructor === xtype;
1599 this.findParentBy(function(p){
1600 return p.constructor.xtype === xtype;
1605 getPositionEl : function(){
1606 return this.positionEl || this.el;
1610 purgeListeners : function(){
1611 Ext.Component.superclass.purgeListeners.call(this);
1613 this.on('beforedestroy', this.clearMons, this, {single: true});
1618 clearMons : function(){
1619 Ext.each(this.mons, function(m){
1620 m.item.un(m.ename, m.fn, m.scope);
1626 createMons: function(){
1629 this.on('beforedestroy', this.clearMons, this, {single: true});
1633 <div id="method-Ext.Component-mon"></div>/**
1634 * <p>Adds listeners to any Observable object (or Elements) which are automatically removed when this Component
1635 * is destroyed. Usage:</p><code><pre>
1636 myGridPanel.mon(myGridPanel.getSelectionModel(), 'selectionchange', handleSelectionChange, null, {buffer: 50});
1638 * <p>or:</p><code><pre>
1639 myGridPanel.mon(myGridPanel.getSelectionModel(), {
1640 selectionchange: handleSelectionChange,
1644 * @param {Observable|Element} item The item to which to add a listener/listeners.
1645 * @param {Object|String} ename The event name, or an object containing event name properties.
1646 * @param {Function} fn Optional. If the <code>ename</code> parameter was an event name, this
1647 * is the handler function.
1648 * @param {Object} scope Optional. If the <code>ename</code> parameter was an event name, this
1649 * is the scope (<code>this</code> reference) in which the handler function is executed.
1650 * @param {Object} opt Optional. If the <code>ename</code> parameter was an event name, this
1651 * is the {@link Ext.util.Observable#addListener addListener} options.
1653 mon : function(item, ename, fn, scope, opt){
1655 if(Ext.isObject(ename)){
1656 var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
1663 if(Ext.isFunction(o[e])){
1666 item: item, ename: e, fn: o[e], scope: o.scope
1668 item.on(e, o[e], o.scope, o);
1670 // individual options
1672 item: item, ename: e, fn: o[e], scope: o.scope
1681 item: item, ename: ename, fn: fn, scope: scope
1683 item.on(ename, fn, scope, opt);
1686 <div id="method-Ext.Component-mun"></div>/**
1687 * Removes listeners that were added by the {@link #mon} method.
1688 * @param {Observable|Element} item The item from which to remove a listener/listeners.
1689 * @param {Object|String} ename The event name, or an object containing event name properties.
1690 * @param {Function} fn Optional. If the <code>ename</code> parameter was an event name, this
1691 * is the handler function.
1692 * @param {Object} scope Optional. If the <code>ename</code> parameter was an event name, this
1693 * is the scope (<code>this</code> reference) in which the handler function is executed.
1695 mun : function(item, ename, fn, scope){
1698 for(var i = 0, len = this.mons.length; i < len; ++i){
1700 if(item === mon.item && ename == mon.ename && fn === mon.fn && scope === mon.scope){
1701 this.mons.splice(i, 1);
1702 item.un(ename, fn, scope);
1710 <div id="method-Ext.Component-nextSibling"></div>/**
1711 * Returns the next component in the owning container
1712 * @return Ext.Component
1714 nextSibling : function(){
1716 var index = this.ownerCt.items.indexOf(this);
1717 if(index != -1 && index+1 < this.ownerCt.items.getCount()){
1718 return this.ownerCt.items.itemAt(index+1);
1724 <div id="method-Ext.Component-previousSibling"></div>/**
1725 * Returns the previous component in the owning container
1726 * @return Ext.Component
1728 previousSibling : function(){
1730 var index = this.ownerCt.items.indexOf(this);
1732 return this.ownerCt.items.itemAt(index-1);
1738 <div id="method-Ext.Component-getBubbleTarget"></div>/**
1739 * Provides the link for Observable's fireEvent method to bubble up the ownership hierarchy.
1740 * @return {Ext.Container} the Container which owns this Component.
1742 getBubbleTarget : function(){
1743 return this.ownerCt;
1747 Ext.reg('component', Ext.Component);</pre>
\r