<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Creating a custom ComboBox item renderer in Flex</title>
	<atom:link href="http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Thu, 18 Mar 2010 20:18:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: bwp</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-7285</link>
		<dc:creator>bwp</dc:creator>
		<pubDate>Wed, 17 Mar 2010 15:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-7285</guid>
		<description>Is there a way to maintain the two lines of text once an item has been selected. I need to display two lines of text in the closed state. Is this possible in Flex 3?</description>
		<content:encoded><![CDATA[<p>Is there a way to maintain the two lines of text once an item has been selected. I need to display two lines of text in the closed state. Is this possible in Flex 3?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: juanabreu</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-6746</link>
		<dc:creator>juanabreu</dc:creator>
		<pubDate>Fri, 08 Jan 2010 05:24:30 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-6746</guid>
		<description>thank you for the awesome post i have a really easy question for someone of your caliber. i ahve more then a couple of columns on my datagrid and i would like to test for the length of the strings and when the string is greated then night i would like to make then red. when i try one column i have no problem as soon as i expand to more then one column i run into trouble can you please help me. 

&lt;pre lang=&quot;actionscript3&quot;&gt;
 if (parseFloat(data.col1.length) != 9){
        (setStyle(&quot;color&quot;, (parseFloat(data.col1.length) != 9) ? NEGATIVE_COLOR : POSITIVE_COLOR))
    }
	if (parseFloat(data.col2.length) &gt; 15){
	(setStyle(&quot;color&quot;, (parseFloat(data.col2.length) &gt; 15) ? NEGATIVE_COLOR : POSITIVE_COLOR))
    }
		//:setStyle(&quot;color&quot;, (parseFloat(data.col2.length) &gt; 15) ? NEGATIVE_COLOR : POSITIVE_COLOR);
    }
    }
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>thank you for the awesome post i have a really easy question for someone of your caliber. i ahve more then a couple of columns on my datagrid and i would like to test for the length of the strings and when the string is greated then night i would like to make then red. when i try one column i have no problem as soon as i expand to more then one column i run into trouble can you please help me.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"> <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">parseFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.col1.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
        <span style="color: #000000;">&#40;</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;color&quot;</span>, <span style="color: #000000;">&#40;</span><span style="color: #004993;">parseFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.col1.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #000000; font-weight:bold;">9</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> NEGATIVE_COLOR <span style="color: #000000; font-weight: bold;">:</span> POSITIVE_COLOR<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
	<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #004993;">parseFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.col2.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
	<span style="color: #000000;">&#40;</span><span style="color: #004993;">setStyle</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;color&quot;</span>, <span style="color: #000000;">&#40;</span><span style="color: #004993;">parseFloat</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">data</span>.col2.<span style="color: #004993;">length</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight:bold;">15</span><span style="color: #000000;">&#41;</span> <span style="color: #000000; font-weight: bold;">?</span> NEGATIVE_COLOR <span style="color: #000000; font-weight: bold;">:</span> POSITIVE_COLOR<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#125;</span>
		<span style="color: #009900;">//:setStyle(&quot;color&quot;, (parseFloat(data.col2.length) &gt; 15) ? NEGATIVE_COLOR : POSITIVE_COLOR);</span>
    <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: ATD</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-6553</link>
		<dc:creator>ATD</dc:creator>
		<pubDate>Tue, 08 Dec 2009 09:56:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-6553</guid>
		<description>Hi,

I tried to adapt this example to Flex 4, but haven&#039;t been able to get it working.</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I tried to adapt this example to Flex 4, but haven&#8217;t been able to get it working.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharat</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5971</link>
		<dc:creator>Sharat</dc:creator>
		<pubDate>Thu, 08 Oct 2009 22:08:52 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5971</guid>
		<description>Peter,

Thanks again! Works like a charm. I dont care about the other handlers and the code does everything I need.

Thanks,
Sharat</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>Thanks again! Works like a charm. I dont care about the other handlers and the code does everything I need.</p>
<p>Thanks,<br />
Sharat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5969</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:52:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5969</guid>
		<description>Or, if you just wanted the easy solution, try the following example which uses E4X to quickly parse the states XML by state name to find the match (so you can set the &lt;code&gt;selectedItem&lt;/code&gt; property):

&lt;pre lang=&quot;mxml&quot;&gt;
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;!-- http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/ --&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
        layout=&quot;vertical&quot;
        verticalAlign=&quot;top&quot;
        backgroundColor=&quot;white&quot;&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            protected function selectStateByName(stateName:String):void {
                var states:XMLList = statesXMLList.(@name == stateName);
                if (states.length() &gt; 0) {
                    comboBox.selectedItem = states[0];
                } else {
                    comboBox.selectedIndex = -1;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:XMLList id=&quot;statesXMLList&quot;&gt;
        &lt;state abbrev=&quot;AL&quot; name=&quot;Alabama&quot; /&gt;
        &lt;state abbrev=&quot;AK&quot; name=&quot;Alaska&quot; /&gt;
        &lt;state abbrev=&quot;AZ&quot; name=&quot;Arizona&quot; /&gt;
        &lt;state abbrev=&quot;AR&quot; name=&quot;Arkansas&quot; /&gt;
        &lt;state abbrev=&quot;CA&quot; name=&quot;California&quot; /&gt;
        &lt;state abbrev=&quot;CO&quot; name=&quot;Colorado&quot; /&gt;
        &lt;state abbrev=&quot;CT&quot; name=&quot;Connecticut&quot; /&gt;
    &lt;/mx:XMLList&gt;

    &lt;mx:ApplicationControlBar dock=&quot;true&quot;&gt;
        &lt;mx:Button label=&quot;Select California&quot;
                themeColor=&quot;haloGreen&quot;
                click=&quot;selectStateByName(&#039;California&#039;);&quot; /&gt;
        &lt;mx:Button label=&quot;Select Oregon&quot;
                themeColor=&quot;red&quot;
                click=&quot;selectStateByName(&#039;Oregon&#039;);&quot; /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:ComboBox id=&quot;comboBox&quot;
            prompt=&quot;Please select a State...&quot;
            dataProvider=&quot;{statesXMLList}&quot;
            rowCount=&quot;3&quot;
            labelField=&quot;@name&quot;
            itemRenderer=&quot;ComboBoxItemRenderer&quot; /&gt;

&lt;/mx:Application&gt;
&lt;/pre&gt;

You&#039;ll notice that the California button selects the correct state, whereas the Oregon button resets the &lt;code&gt;selectedIndex&lt;/code&gt; property to -1, since no matches were found in the XML. Also note that I haven&#039;t tested the code very thoroughly. I don&#039;t know how it would handle multiple states named &quot;California&quot; in the data provider, and I also never tested this in a &lt;code&gt;initialize&lt;/code&gt; or &lt;code&gt;creationComplete&lt;/code&gt; handler to see if it correctly selects a state by default.

Peter</description>
		<content:encoded><![CDATA[<p>Or, if you just wanted the easy solution, try the following example which uses E4X to quickly parse the states XML by state name to find the match (so you can set the <code>selectedItem</code> property):</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;top&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            protected function selectStateByName(stateName:String):void {</span>
<span style="color: #339933;">                var states:XMLList = statesXMLList.(@name == stateName);</span>
<span style="color: #339933;">                if (states.length() &gt; 0) {</span>
<span style="color: #339933;">                    comboBox.selectedItem = states[0];</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    comboBox.selectedIndex = -1;</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLList</span> id=<span style="color: #ff0000;">&quot;statesXMLList&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;AL&quot;</span> name=<span style="color: #ff0000;">&quot;Alabama&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;AK&quot;</span> name=<span style="color: #ff0000;">&quot;Alaska&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;AZ&quot;</span> name=<span style="color: #ff0000;">&quot;Arizona&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;AR&quot;</span> name=<span style="color: #ff0000;">&quot;Arkansas&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;CA&quot;</span> name=<span style="color: #ff0000;">&quot;California&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;CO&quot;</span> name=<span style="color: #ff0000;">&quot;Colorado&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;">&lt;state abbrev=<span style="color: #ff0000;">&quot;CT&quot;</span> name=<span style="color: #ff0000;">&quot;Connecticut&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:XMLList</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ApplicationControlBar</span> dock=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Select California&quot;</span></span>
<span style="color: #000000;">                themeColor=<span style="color: #ff0000;">&quot;haloGreen&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;selectStateByName('California');&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Button</span> label=<span style="color: #ff0000;">&quot;Select Oregon&quot;</span></span>
<span style="color: #000000;">                themeColor=<span style="color: #ff0000;">&quot;red&quot;</span></span>
<span style="color: #000000;">                click=<span style="color: #ff0000;">&quot;selectStateByName('Oregon');&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ApplicationControlBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ComboBox</span> id=<span style="color: #ff0000;">&quot;comboBox&quot;</span></span>
<span style="color: #000000;">            prompt=<span style="color: #ff0000;">&quot;Please select a State...&quot;</span></span>
<span style="color: #000000;">            dataProvider=<span style="color: #ff0000;">&quot;{statesXMLList}&quot;</span></span>
<span style="color: #000000;">            rowCount=<span style="color: #ff0000;">&quot;3&quot;</span></span>
<span style="color: #000000;">            labelField=<span style="color: #ff0000;">&quot;@name&quot;</span></span>
<span style="color: #000000;">            itemRenderer=<span style="color: #ff0000;">&quot;ComboBoxItemRenderer&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>You&#8217;ll notice that the California button selects the correct state, whereas the Oregon button resets the <code>selectedIndex</code> property to -1, since no matches were found in the XML. Also note that I haven&#8217;t tested the code very thoroughly. I don&#8217;t know how it would handle multiple states named &#8220;California&#8221; in the data provider, and I also never tested this in a <code>initialize</code> or <code>creationComplete</code> handler to see if it correctly selects a state by default.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharat</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5968</link>
		<dc:creator>Sharat</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:47:16 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5968</guid>
		<description>Peter,

Thanks a lot. This is exactly what I was looking for.

Sharat</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>Thanks a lot. This is exactly what I was looking for.</p>
<p>Sharat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5967</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:40:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5967</guid>
		<description>@Sharat,

Check out this article by Adobe&#039;s Alex Harui; &lt;a href=&quot;http://blogs.adobe.com/aharui/2008/01/selecteditem_and_combobox.html&quot; rel=&quot;nofollow&quot;&gt;&quot;SelectedItem and ComboBox&quot;&lt;/a&gt;.

Peter</description>
		<content:encoded><![CDATA[<p>@Sharat,</p>
<p>Check out this article by Adobe&#8217;s Alex Harui; <a href="http://blogs.adobe.com/aharui/2008/01/selecteditem_and_combobox.html" rel="nofollow">&#8220;SelectedItem and ComboBox&#8221;</a>.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharat</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5966</link>
		<dc:creator>Sharat</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:37:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5966</guid>
		<description>I tried doing selectedItem = &quot;text&quot; and it doesn&#039;t seem to work.</description>
		<content:encoded><![CDATA[<p>I tried doing selectedItem = &#8220;text&#8221; and it doesn&#8217;t seem to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sharat</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5965</link>
		<dc:creator>Sharat</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5965</guid>
		<description>Peter,

Thanks for the quick response. Yes, that would be the easiest but is there a way to do it based on value? In my application, I get the text, say &quot;California&quot; and the index might not be consistent all the time.

Thanks,
Sharat</description>
		<content:encoded><![CDATA[<p>Peter,</p>
<p>Thanks for the quick response. Yes, that would be the easiest but is there a way to do it based on value? In my application, I get the text, say &#8220;California&#8221; and the index might not be consistent all the time.</p>
<p>Thanks,<br />
Sharat</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/comment-page-1/#comment-5964</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Thu, 08 Oct 2009 19:30:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/#comment-5964</guid>
		<description>@Sharat,

The easiest way would be to set the &lt;code&gt;selectedIndex&lt;/code&gt; property to 4.

Peter</description>
		<content:encoded><![CDATA[<p>@Sharat,</p>
<p>The easiest way would be to set the <code>selectedIndex</code> property to 4.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
</channel>
</rss>
