<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Log on JavaScript &#187; ExtJS Components</title>
	<atom:link href="http://www.jslog.com/tag/extjs-components/feed" rel="self" type="application/rss+xml" />
	<link>http://www.jslog.com</link>
	<description></description>
	<lastBuildDate>Thu, 21 Jul 2011 11:00:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Quick tips on ExtJS and JavaScript</title>
		<link>http://www.jslog.com/quick-tips-on-extjs-and-javascript</link>
		<comments>http://www.jslog.com/quick-tips-on-extjs-and-javascript#comments</comments>
		<pubDate>Thu, 18 Feb 2010 19:45:04 +0000</pubDate>
		<dc:creator>radu</dc:creator>
				<category><![CDATA[ExtJS Components]]></category>
		<category><![CDATA[quick tips]]></category>
		<category><![CDATA[utilities]]></category>
		<category><![CDATA[ExtJS]]></category>

		<guid isPermaLink="false">http://www.jslog.com/?p=147</guid>
		<description><![CDATA[Tips on JavaScript and ExtJS: using the ExtJS ref config option on panels and other components.]]></description>
			<content:encoded><![CDATA[<p>I will usually try to post a major and well documented <b>article</b> on this blog <b>every week</b>. But during the week, I will also have smaller tips, just a few lines short, about small things/improvements that can make your life better using JavaScript and ExtJS.</p>
<p>Here is the first one:</p>
<p>
<h2>Use the <b>ref</b> config option in ExtJS</h2>
<p><span id="more-147"></span></p>
<pre class="prettyprint">

var win = new Ext.Window({
    layout: 'fit',
    width: 300,
    height: 200,
    title: 'my window',
    items: [{
            <b>ref</b>: 'panel',
            xtype: 'panel', layout: 'form',
            frame: true, defaults: {xtype: 'textfield'},
            items: [
                {<b>ref</b>: '../nameField', fieldLabel: 'Name'},
                {<b>ref</b>: 'age', fieldLabel: 'Age'}
            ]
    }]
});

win.show();
//so now, with the above ref options, you can do:
win.nameField.setValue('name here');
win.panel.age.setValue(20);
</pre>
<p>Notice in the example above that setting ref <b>age</b> config puts a reference &#8220;age&#8221; in the panel containing the text field, while puting a ref <b>../nameField</b> sets a &#8220;nameField&#8221; reference on the component one more level up, that is, the containing window. In this way, you can navigate many levels, each &#8220;/&#8221; navigating one more level upwards.<br />
In this next example, I introduce another level of nesting, by artificially adding another panel, in order to illustrate the navigation with multiple slashes.</p>
<pre class="prettyprint">

var win = new Ext.Window({
    layout: 'fit',
    width: 300,
    height: 200,
    title: 'my window',
    items: [{
            ref: 'panel',
            xtype: 'panel', layout: 'form',
            frame: true, defaults: {xtype: 'textfield'},
            items: [

                {
                     xtype: 'panel', fieldLabel: 'Name', layout: 'fit',
                     items: [{xtype: 'textfield', ref: '//nameField'}]
                     //notice above, two slashes, which puts
                     //nameField reference on the containing window (two levels)
                },
                {ref: 'age', fieldLabel: 'Age'}
            ]
    }]
});

win.show();
win.nameField.setValue('name here');
win.panel.age.setValue(20);
</pre>
<p>Please see <a href="http://www.extjs.com/deploy/dev/docs/?class=Ext.Component&#038;member=ref">Ext.Component &#8220;ref&#8221; reference</a> from the Ext API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jslog.com/quick-tips-on-extjs-and-javascript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

