<?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>Flex Examples &#187; headerWordWrap</title>
	<atom:link href="http://blog.flexexamples.com/tag/headerwordwrap/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Aligning the header text in a DataGrid column in Flex</title>
		<link>http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 06:02:59 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DataGridColumn]]></category>
		<category><![CDATA[headerStyleName]]></category>
		<category><![CDATA[headerWordWrap]]></category>
		<category><![CDATA[textAlign]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can set the text alignment on a Flex DataGrid control&#8217;s DataGridColumn by setting the headerStyleName and textAlign styles.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/ --&#62; &#60;mx:Application name="DataGrid_headerStyleName_textAlign_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.events.ListEvent; private function comboBox_change(evt:ListEvent):void { var [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can set the text alignment on a Flex DataGrid control&#8217;s DataGridColumn by setting the <code>headerStyleName</code> and <code>textAlign</code> styles.</p>
<p>Full code after the jump.</p>
<p><span id="more-800"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/ --&gt;
&lt;mx:Application name="DataGrid_headerStyleName_textAlign_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ListEvent;

            private function comboBox_change(evt:ListEvent):void {
                var value:String = comboBox.selectedItem.toString();
                var styleName:String = "." + dataGrid.getStyle("headerStyleName");
                var cssDecl:CSSStyleDeclaration = StyleManager.getStyleDeclaration(styleName);
                cssDecl.setStyle("textAlign", value);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="dp" source="data/products.xml" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="textAlign:"&gt;
                &lt;mx:ComboBox id="comboBox"
                        dataProvider="[left,center,right,justify]"
                        change="comboBox_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{dp.product}"
            rowCount="5"
            verticalScrollPolicy="on"
            width="300"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id="dataGridColumn1"
                    dataField="@name"
                    headerText="This is a column with a long title:"
                    headerWordWrap="true"
                    minWidth="80" /&gt;
            &lt;mx:DataGridColumn id="dataGridColumn2"
                    dataField="@price"
                    headerText="Price:"
                    headerWordWrap="false"
                    minWidth="20" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/main.html" width="100%" height="250"></iframe></p>
<p>You can also set the text alignment in an external .CSS file or &lt;mx:Style /&gt; block, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/ --&gt;
&lt;mx:Application name="DataGrid_headerStyleName_textAlign_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Style&gt;
        DataGrid {
            headerStyleName: centerBold;
        }

        .centerBold {
            fontWeight: bold;
            textAlign: center;
        }
    &lt;/mx:Style&gt;

    &lt;mx:XML id="dp" source="data/products.xml" /&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{dp.product}"
            rowCount="5"
            verticalScrollPolicy="on"
            width="300"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id="dataGridColumn1"
                    dataField="@name"
                    headerText="This is a column with a long title:"
                    headerWordWrap="true"
                    minWidth="80" /&gt;
            &lt;mx:DataGridColumn id="dataGridColumn2"
                    dataField="@price"
                    headerText="Price:"
                    headerWordWrap="false"
                    minWidth="20" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_headerStyleName_textAlign_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/ --&gt;
&lt;mx:Application name="DataGrid_headerStyleName_textAlign_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import flash.text.TextFormatAlign;

            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.controls.ComboBox;
            import mx.controls.DataGrid;
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.core.ScrollPolicy;
            import mx.events.ListEvent;

            private const XML_URL:String = "data/products.xml";

            private var urlLoader:URLLoader;
            private var dp:XML;
            private var comboBox:ComboBox;
            private var dataGrid:DataGrid;
            private var dataGridColumn1:DataGridColumn;
            private var dataGridColumn2:DataGridColumn;

            private function init():void {
                urlLoader = new URLLoader();
                urlLoader.addEventListener(Event.COMPLETE,
                            urlLoader_complete);
                urlLoader.load(new URLRequest(XML_URL));

                var arr:Array = [];
                arr.push(TextFormatAlign.LEFT);
                arr.push(TextFormatAlign.CENTER);
                arr.push(TextFormatAlign.RIGHT);
                arr.push(TextFormatAlign.JUSTIFY);

                comboBox = new ComboBox();
                comboBox.dataProvider = arr;
                comboBox.addEventListener(ListEvent.CHANGE,
                            comboBox_change);

                var formItem:FormItem = new FormItem();
                formItem.label = "textAlign:";
                formItem.addChild(comboBox);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addChild(formItem);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(form);
                addChildAt(appControlBar, 0);

                dataGridColumn1 = new DataGridColumn("@name");
                dataGridColumn1.headerText = "This is a column with a long title:";
                dataGridColumn1.headerWordWrap = true;
                dataGridColumn1.minWidth = 80;

                dataGridColumn2 = new DataGridColumn("@price");
                dataGridColumn2.headerText = "Price:";
                dataGridColumn2.headerWordWrap = false;
                dataGridColumn2.minWidth = 20;

                dataGrid = new DataGrid();
                dataGrid.rowCount = 5;
                dataGrid.verticalScrollPolicy = ScrollPolicy.ON;
                dataGrid.width = 300;
                dataGrid.columns = [dataGridColumn1, dataGridColumn2];
                addChild(dataGrid);
            }

            private function urlLoader_complete(evt:Event):void {
                dataGrid.dataProvider = XML(evt.target.data).product;
            }

            private function comboBox_change(evt:ListEvent):void {
                var value:String = comboBox.selectedItem.toString();
                var styleName:String = "." + dataGrid.getStyle("headerStyleName");
                var cssDecl:CSSStyleDeclaration;
                cssDecl = StyleManager.getStyleDeclaration(styleName);
                cssDecl.setStyle("textAlign", value);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Aligning the header text in a DataGrid column in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/',contentID: 'post-800',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'headerStyleName,headerWordWrap,textAlign',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/09/16/aligning-the-header-text-in-a-datagrid-column-in-flex/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Toggling word wrap on a DataGrid column header in Flex</title>
		<link>http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/#comments</comments>
		<pubDate>Sun, 14 Sep 2008 14:12:07 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DataGridColumn]]></category>
		<category><![CDATA[headerWordWrap]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can toggle word wrapping on a Flex DataGrid control&#8217;s DataGridColumn by setting the headerWordWrap property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/ --&#62; &#60;mx:Application name="DataGridColumn_headerWordWrap_test" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top" backgroundColor="white"&#62; &#60;mx:XML id="dp" source="data/products.xml" /&#62; &#60;mx:ApplicationControlBar dock="true"&#62; &#60;mx:Form styleName="plain"&#62; &#60;mx:FormItem label="headerWordWrap:"&#62; &#60;mx:CheckBox id="checkBox" [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can toggle word wrapping on a Flex DataGrid control&#8217;s DataGridColumn by setting the <code>headerWordWrap</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-797"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/ --&gt;
&lt;mx:Application name="DataGridColumn_headerWordWrap_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:XML id="dp" source="data/products.xml" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="headerWordWrap:"&gt;
                &lt;mx:CheckBox id="checkBox" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="rowCount:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="2"
                        maximum="10"
                        value="6"
                        snapInterval="1"
                        tickInterval="1"
                        liveDragging="true"
                        showTrackHighlight="true" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{dp.product}"
            rowCount="{slider.value}"
            verticalScrollPolicy="on"
            width="300"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id="dataGridColumn1"
                    dataField="@name"
                    headerText="This is a column with a long title:"
                    headerWordWrap="{checkBox.selected}"
                    minWidth="80" /&gt;
            &lt;mx:DataGridColumn id="dataGridColumn2"
                    dataField="@price"
                    headerText="Price:"
                    headerWordWrap="false"
                    minWidth="20" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p>And the XML file, <em>data/products.xml</em>, is as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/ --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;products<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 1&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;1.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 2&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;2.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 3&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;3.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 4&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;4.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 5&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;5.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 6&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;6.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 7&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;7.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 8&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;8.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 9&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;9.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;product</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Product 0&quot;</span> <span style="color: #000066;">price</span>=<span style="color: #ff0000;">&quot;0.99&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/products<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/main.html" width="100%" height="400"></iframe></p>
<p>You can also set the <code>headerWordWrap</code> property using ActionScript, as seen in the following example:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/ --&gt;
&lt;mx:Application name="DataGridColumn_headerWordWrap_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function checkBox_change(evt:Event):void {
                dataGridColumn1.headerWordWrap = checkBox.selected;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="dp" source="data/products.xml" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="headerWordWrap:"&gt;
                &lt;mx:CheckBox id="checkBox"
                        change="checkBox_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="rowCount:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="2"
                        maximum="10"
                        value="6"
                        snapInterval="1"
                        tickInterval="1"
                        liveDragging="true"
                        showTrackHighlight="true" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{dp.product}"
            rowCount="{slider.value}"
            verticalScrollPolicy="on"
            width="300"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn id="dataGridColumn1"
                    dataField="@name"
                    headerText="This is a column with a long title:"
                    minWidth="80" /&gt;
            &lt;mx:DataGridColumn id="dataGridColumn2"
                    dataField="@price"
                    headerText="Price:"
                    headerWordWrap="false"
                    minWidth="20" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p>Due to popular demand, here is the &#8220;same&#8221; example in a more ActionScript friendly format:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_headerWordWrap_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/ --&gt;
&lt;mx:Application name="DataGridColumn_headerWordWrap_test"
        xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="top"
        backgroundColor="white"
        initialize="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.containers.ApplicationControlBar;
            import mx.containers.Form;
            import mx.containers.FormItem;
            import mx.controls.CheckBox;
            import mx.controls.DataGrid;
            import mx.controls.HSlider;
            import mx.controls.dataGridClasses.DataGridColumn;
            import mx.core.ScrollPolicy;
            import mx.events.SliderEvent;

            private var checkBox:CheckBox;
            private var slider:HSlider;
            private var dataGrid:DataGrid;
            private var dataGridColumn1:DataGridColumn;
            private var dataGridColumn2:DataGridColumn;

            private function init():void {
                checkBox = new CheckBox();
                checkBox.addEventListener(Event.CHANGE,
                            checkBox_change);

                slider = new HSlider();
                slider.minimum = 2;
                slider.maximum = 10;
                slider.value = 6;
                slider.snapInterval = 1;
                slider.tickInterval = 1;
                slider.liveDragging = true;
                slider.setStyle("showTrackHighlight", true);
                slider.addEventListener(SliderEvent.CHANGE,
                            slider_change);

                var formItem1:FormItem = new FormItem();
                formItem1.label = "headerWordWrap:";
                formItem1.addChild(checkBox);

                var formItem2:FormItem = new FormItem();
                formItem2.label = "rowCount:";
                formItem2.addChild(slider);

                var form:Form = new Form();
                form.styleName = "plain";
                form.addChild(formItem1);
                form.addChild(formItem2);

                var appControlBar:ApplicationControlBar;
                appControlBar = new ApplicationControlBar();
                appControlBar.dock = true;
                appControlBar.addChild(form);
                addChildAt(appControlBar, 0);

                dataGridColumn1 = new DataGridColumn();
                dataGridColumn1.dataField = "@name";
                dataGridColumn1.headerText = "This is a column with a long title:";
                dataGridColumn1.minWidth = 80;

                dataGridColumn2 = new DataGridColumn();
                dataGridColumn2.dataField = "@price";
                dataGridColumn2.headerText = "Price:";
                dataGridColumn2.headerWordWrap = false;
                dataGridColumn2.minWidth = 20;

                dataGrid = new DataGrid();
                dataGrid.columns = [dataGridColumn1, dataGridColumn2];
                dataGrid.dataProvider = dp.product;
                dataGrid.rowCount = 6;
                dataGrid.verticalScrollPolicy = ScrollPolicy.ON;
                dataGrid.width = 300;
                addChild(dataGrid);
            }

            private function checkBox_change(evt:Event):void {
                dataGridColumn1.headerWordWrap = checkBox.selected;
            }

            private function slider_change(evt:SliderEvent):void {
                dataGrid.rowCount = evt.value;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XML id="dp" source="data/products.xml" /&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Toggling word wrap on a DataGrid column header in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/',contentID: 'post-797',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'headerWordWrap',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/09/14/toggling-word-wrap-on-a-datagrid-column-header-in-flex/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

