<?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 variable row height item renderer on a ComboBox control in Flex</title>
	<atom:link href="http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Sun, 12 Feb 2012 19:26:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Vijay Anand Mareddy</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-8620</link>
		<dc:creator>Vijay Anand Mareddy</dc:creator>
		<pubDate>Wed, 08 Dec 2010 15:03:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-8620</guid>
		<description>Scott, 
This works for me.

private var internalDropdownFactory:ClassFactory = 
new ClassFactory(SeparatorList);
-------------------------------------------------------------------------------

public class SeparatorList extends List {
	
		public function SeparatorList() {
			super();
			itemRenderer = new ClassFactory(SeparatorListItemRenderer);
			showDataTips = true;
		}
	
	    /**
	     *  @private
	     *  Determines if the itemrenderer is a separator. If so, return null to prevent separators
	     *  from highlighting and emitting menu-level events. 
	     */
	    override protected function mouseEventToItemRenderer(event:MouseEvent):IListItemRenderer {
	        var row:IListItemRenderer = super.mouseEventToItemRenderer(event);
	        
	        if (row &amp;&amp; row.data &amp;&amp; row.data.hasOwnProperty(&#039;separator&#039;) &amp;&amp; row.data.separator){
	            return null;
	        } else {
	        	return row;
	        } 
	    }
	    
	    /** 
		 *	 Override measuredHeight to maximum possible stageHeightAvailable.
	     *   
	     **/
	    override protected function measure():void {
        	super.measure();
            if(!stage &#124;&#124; !owner is ComboBox &#124;&#124; !dataProvider) return;
                    		        		
			var pt:Point = stage.globalToLocal(owner.localToGlobal(new Point(0, 0)));
    		var stageHeightAvailable:Number = Math.max(pt.y,screen.height - pt.y) - (2*rowHeight);
    		var calcHeightByItems:Number = measureHeightOfItems()+rowHeight;
    		
        	measuredHeight = Math.min(stageHeightAvailable,calcHeightByItems);
        				    
//			trace(&#039;*****height:&#039;+height);
//			trace(&#039;*****y:&#039;+y);
//			trace(&#039;*****pt.y:&#039;+pt.y);
//			trace(&#039;*****screen.y:&#039;+screen.y);
//			trace(&#039;*****screen.height:&#039;+screen.height);
//			trace(&#039;*****screen.height-pt.y:&#039;+(screen.height - pt.y));				    				    				    
//			trace(&#039;*****rowHeight:&#039;+rowHeight);
//			trace(&#039;*****calcHeightByItems:&#039;+calcHeightByItems);
//			trace(&#039;*****stageHeightAvailable:&#039;+stageHeightAvailable);			    
//			trace(&#039;*****measuredHeight:&#039;+measuredHeight);
			    			    
		    
    	}//measure
	
	}//SeparatorList</description>
		<content:encoded><![CDATA[<p>Scott,<br />
This works for me.</p>
<p>private var internalDropdownFactory:ClassFactory =<br />
new ClassFactory(SeparatorList);<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>public class SeparatorList extends List {</p>
<p>		public function SeparatorList() {<br />
			super();<br />
			itemRenderer = new ClassFactory(SeparatorListItemRenderer);<br />
			showDataTips = true;<br />
		}</p>
<p>	    /**<br />
	     *  @private<br />
	     *  Determines if the itemrenderer is a separator. If so, return null to prevent separators<br />
	     *  from highlighting and emitting menu-level events.<br />
	     */<br />
	    override protected function mouseEventToItemRenderer(event:MouseEvent):IListItemRenderer {<br />
	        var row:IListItemRenderer = super.mouseEventToItemRenderer(event);</p>
<p>	        if (row &amp;&amp; row.data &amp;&amp; row.data.hasOwnProperty(&#8216;separator&#8217;) &amp;&amp; row.data.separator){<br />
	            return null;<br />
	        } else {<br />
	        	return row;<br />
	        }<br />
	    }</p>
<p>	    /**<br />
		 *	 Override measuredHeight to maximum possible stageHeightAvailable.<br />
	     *<br />
	     **/<br />
	    override protected function measure():void {<br />
        	super.measure();<br />
            if(!stage || !owner is ComboBox || !dataProvider) return;</p>
<p>			var pt:Point = stage.globalToLocal(owner.localToGlobal(new Point(0, 0)));<br />
    		var stageHeightAvailable:Number = Math.max(pt.y,screen.height &#8211; pt.y) &#8211; (2*rowHeight);<br />
    		var calcHeightByItems:Number = measureHeightOfItems()+rowHeight;</p>
<p>        	measuredHeight = Math.min(stageHeightAvailable,calcHeightByItems);</p>
<p>//			trace(&#8216;*****height:&#8217;+height);<br />
//			trace(&#8216;*****y:&#8217;+y);<br />
//			trace(&#8216;*****pt.y:&#8217;+pt.y);<br />
//			trace(&#8216;*****screen.y:&#8217;+screen.y);<br />
//			trace(&#8216;*****screen.height:&#8217;+screen.height);<br />
//			trace(&#8216;*****screen.height-pt.y:&#8217;+(screen.height &#8211; pt.y));<br />
//			trace(&#8216;*****rowHeight:&#8217;+rowHeight);<br />
//			trace(&#8216;*****calcHeightByItems:&#8217;+calcHeightByItems);<br />
//			trace(&#8216;*****stageHeightAvailable:&#8217;+stageHeightAvailable);<br />
//			trace(&#8216;*****measuredHeight:&#8217;+measuredHeight);</p>
<p>    	}//measure</p>
<p>	}//SeparatorList</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pratik</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-8587</link>
		<dc:creator>Pratik</dc:creator>
		<pubDate>Thu, 02 Dec 2010 10:47:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-8587</guid>
		<description>Thanks for tips :)</description>
		<content:encoded><![CDATA[<p>Thanks for tips :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-7338</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 23 Mar 2010 23:06:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-7338</guid>
		<description>addition to #2:
And display all the lines of multi-line selections in the label area.

Steve</description>
		<content:encoded><![CDATA[<p>addition to #2:<br />
And display all the lines of multi-line selections in the label area.</p>
<p>Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-7336</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 23 Mar 2010 23:05:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-7336</guid>
		<description>@Peter

That really helped.  Two other things I would like to do:
1. adjust the dropdown height depending on the height of the rows available.  (e.g. if I have 2 rows, 1 height=20 and 1 height=60, set to 80, etc.)
2. adjust the label area height depending on the height of the selected row.

Steve</description>
		<content:encoded><![CDATA[<p>@Peter</p>
<p>That really helped.  Two other things I would like to do:<br />
1. adjust the dropdown height depending on the height of the rows available.  (e.g. if I have 2 rows, 1 height=20 and 1 height=60, set to 80, etc.)<br />
2. adjust the label area height depending on the height of the selected row.</p>
<p>Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter deHaan</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-7334</link>
		<dc:creator>Peter deHaan</dc:creator>
		<pubDate>Tue, 23 Mar 2010 22:04:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-7334</guid>
		<description>@Steve,

Try setting the dropdown height in the open handler:
&lt;pre lang=&quot;mxml&quot;&gt;
&lt;mx:Script&gt;
    &lt;![CDATA[
        import mx.events.DropdownEvent;
        
        private function comboBox_open(evt:DropdownEvent):void {
            ComboBox(evt.currentTarget).dropdown.variableRowHeight = true;
            ComboBox(evt.currentTarget).dropdown.height = 50;
        }
    ]]&gt;
&lt;/mx:Script&gt;
&lt;/pre&gt;

Because the &lt;code&gt;open&lt;/code&gt; event is dispatched &lt;i&gt;after&lt;/i&gt; the ComboBox is opened, you may want to set the ComboBox control&#039;s &lt;code&gt;openDuration&lt;/code&gt; style to 1ms so the resize isn&#039;t as noticeable.

Peter</description>
		<content:encoded><![CDATA[<p>@Steve,</p>
<p>Try setting the dropdown height in the open handler:</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">    &lt;![CDATA[</span>
<span style="color: #339933;">        import mx.events.DropdownEvent;</span>
&nbsp;
<span style="color: #339933;">        private function comboBox_open(evt:DropdownEvent):void {</span>
<span style="color: #339933;">            ComboBox(evt.currentTarget).dropdown.variableRowHeight = true;</span>
<span style="color: #339933;">            ComboBox(evt.currentTarget).dropdown.height = 50;</span>
<span style="color: #339933;">        }</span>
<span style="color: #339933;">    ]]&gt;</span>
<span style="color: #339933;">&lt;/mx:Script&gt;</span></pre></div></div>

<p>Because the <code>open</code> event is dispatched <i>after</i> the ComboBox is opened, you may want to set the ComboBox control&#8217;s <code>openDuration</code> style to 1ms so the resize isn&#8217;t as noticeable.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-7333</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Tue, 23 Mar 2010 21:46:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-7333</guid>
		<description>This was very helpful.  Thanks.
Is there anyway to adjust the height of the dropdown when it opens, other than the rowCount?  I have two answers in one of my dropdown; the first is short and the second is long.  The comboBox then sets the rowCount to 2 and determines the height of the dropdown by multiplying the rowCount by the height of the first row.  This forces the user to scroll to see the entire second item.
Thanks,
Steve</description>
		<content:encoded><![CDATA[<p>This was very helpful.  Thanks.<br />
Is there anyway to adjust the height of the dropdown when it opens, other than the rowCount?  I have two answers in one of my dropdown; the first is short and the second is long.  The comboBox then sets the rowCount to 2 and determines the height of the dropdown by multiplying the rowCount by the height of the first row.  This forces the user to scroll to see the entire second item.<br />
Thanks,<br />
Steve</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott Delamater</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-6760</link>
		<dc:creator>Scott Delamater</dc:creator>
		<pubDate>Tue, 12 Jan 2010 21:28:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-6760</guid>
		<description>If you&#039;re trying to do this same thing without using an inline itemRenderer (e.g., just using the default ListItemRenderer, or a a custom renderer that extends that class), you also need to set the wordWrap property of the dropdown box to true:
&lt;pre lang=&quot;actionscript3&quot;&gt;
private function comboBox_open(evt:DropdownEvent):void 
{
     evt.currentTarget.dropdown.wordWrap = true;
     evt.currentTarget.dropdown.variableRowHeight = true;
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>If you&#8217;re trying to do this same thing without using an inline itemRenderer (e.g., just using the default ListItemRenderer, or a a custom renderer that extends that class), you also need to set the wordWrap property of the dropdown box to true:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> comboBox_open<span style="color: #000000;">&#40;</span>evt<span style="color: #000066; font-weight: bold;">:</span>DropdownEvent<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
<span style="color: #000000;">&#123;</span>
     evt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">currentTarget</span><span style="color: #000066; font-weight: bold;">.</span>dropdown<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">wordWrap</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
     evt<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">currentTarget</span><span style="color: #000066; font-weight: bold;">.</span>dropdown<span style="color: #000066; font-weight: bold;">.</span>variableRowHeight = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

]]></content:encoded>
	</item>
	<item>
		<title>By: lily</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-4571</link>
		<dc:creator>lily</dc:creator>
		<pubDate>Wed, 15 Jul 2009 12:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-4571</guid>
		<description>but when the content is &quot;gy&quot; ,it does&#039;t work. How to solve it?</description>
		<content:encoded><![CDATA[<p>but when the content is &#8220;gy&#8221; ,it does&#8217;t work. How to solve it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Srinivas Kusunam</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-3439</link>
		<dc:creator>Srinivas Kusunam</dc:creator>
		<pubDate>Tue, 26 May 2009 17:52:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-3439</guid>
		<description>Thanks for sharing this trick infact many tricks :)</description>
		<content:encoded><![CDATA[<p>Thanks for sharing this trick infact many tricks :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: euni</title>
		<link>http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/comment-page-1/#comment-3440</link>
		<dc:creator>euni</dc:creator>
		<pubDate>Mon, 27 Oct 2008 06:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.flexexamples.com/2008/07/04/creating-a-variable-row-height-item-renderer-on-a-combobox-control-in-flex/#comment-3440</guid>
		<description>Thanks for many examples.

i hava a item renderer problem on DataGridColumn.
There are comboboxes on DataGridColumn and users can choose a column item.
But when grid is scrolled all DataGridColumns are initialized.
In my opinion, Flex draw all grid again when scrolled.

plz tell me the solution.</description>
		<content:encoded><![CDATA[<p>Thanks for many examples.</p>
<p>i hava a item renderer problem on DataGridColumn.<br />
There are comboboxes on DataGridColumn and users can choose a column item.<br />
But when grid is scrolled all DataGridColumns are initialized.<br />
In my opinion, Flex draw all grid again when scrolled.</p>
<p>plz tell me the solution.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

