<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Formatting a Flex DataGrid control using a custom item renderer</title>
	<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Fri, 05 Dec 2008 11:30:04 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Dan</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-16613</link>
		<author>Dan</author>
		<pubDate>Fri, 07 Nov 2008 18:01:34 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-16613</guid>
		<description>Can an ItemEditor dispatch their own events? If so, how do you set an event listener to capture the event?</description>
		<content:encoded><![CDATA[<p>Can an ItemEditor dispatch their own events? If so, how do you set an event listener to capture the event?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15898</link>
		<author>peterd</author>
		<pubDate>Sat, 27 Sep 2008 15:33:14 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15898</guid>
		<description>Pierre,

In PriceLabel.as, it looks like I hard-coded the column data field (&lt;code&gt;data.@price&lt;/code&gt;) into the item renderer. Of course, you could create a new subclass for each different data field (CostLabel.as, etc.), but that would probably not be the best approach.

I think the better approach would be to look at my coworker Alex Harui's solution to this, as he is ridiculously smarter than I am: &lt;a href="http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html" rel="nofollow"&gt;&lt;u&gt;"Thinking About Item Renderers"&lt;/u&gt;&lt;/a&gt;. Specifically, I was reading the &lt;em&gt;Text Color and Styles in Item Renderers&lt;/em&gt; section. He shows how you can extend both the DataGridColumn and DataGridItemRenderer classes, and create a custom &lt;code&gt;stylesFunction()&lt;/code&gt; method which evaluates the data in a column &lt;em&gt;without&lt;/em&gt; hard-coding specific column names.

Peter</description>
		<content:encoded><![CDATA[<p>Pierre,</p>
<p>In PriceLabel.as, it looks like I hard-coded the column data field (<code><a href="mailto:data.@price">data.@price</a></code>) into the item renderer. Of course, you could create a new subclass for each different data field (CostLabel.as, etc.), but that would probably not be the best approach.</p>
<p>I think the better approach would be to look at my coworker Alex Harui&#8217;s solution to this, as he is ridiculously smarter than I am: <a href="http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html" rel="nofollow"><u>&#8220;Thinking About Item Renderers&#8221;</u></a>. Specifically, I was reading the <em>Text Color and Styles in Item Renderers</em> section. He shows how you can extend both the DataGridColumn and DataGridItemRenderer classes, and create a custom <code>stylesFunction()</code> method which evaluates the data in a column <em>without</em> hard-coding specific column names.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pierre</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15896</link>
		<author>Pierre</author>
		<pubDate>Sat, 27 Sep 2008 14:02:36 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15896</guid>
		<description>Hello,

Thank for this very interesting example.

If a change the source with an arraycollection, what kind of modifications i must do in the PriceLabel.as field ?

Thanks

Best Regards</description>
		<content:encoded><![CDATA[<p>Hello,</p>
<p>Thank for this very interesting example.</p>
<p>If a change the source with an arraycollection, what kind of modifications i must do in the PriceLabel.as field ?</p>
<p>Thanks</p>
<p>Best Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: donkelito</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15235</link>
		<author>donkelito</author>
		<pubDate>Thu, 04 Sep 2008 11:37:58 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-15235</guid>
		<description>hi,

i have developed a similar example. the difference is that my item renderer is a linkbutton extend class. The override function is the next:

&lt;pre class="code"&gt;
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
    super.updateDisplayList(unscaledWidth, unscaledHeight);

    var spattern:String = listData.label;

    var tic:TextImageClass = new TextImageClass(spattern);
    if (tic.tranform()) {
        this.setStyle("paddingRight",Number(35));
        if (tic.displayObject != null) {
            this.setStyle("icon",tic.imageClass);
            this.labelPlacement = ButtonLabelPlacement.LEFT;
        }
        if (tic.uiTextField != null) {
            this.label = tic.uiTextField.text;
        }
    }
}
&lt;/pre&gt;

my problem is when i sort a column. When i click the column header, the data rows are changed  but not sorted... but i move the mouse cursor over the rows... magically... the data in the columns are going to appearing sorted.

any idea?
thanks, congratulations, it´s a great website</description>
		<content:encoded><![CDATA[<p>hi,</p>
<p>i have developed a similar example. the difference is that my item renderer is a linkbutton extend class. The override function is the next:</p>
<pre class="code">
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
    super.updateDisplayList(unscaledWidth, unscaledHeight);

    var spattern:String = listData.label;

    var tic:TextImageClass = new TextImageClass(spattern);
    if (tic.tranform()) {
        this.setStyle("paddingRight",Number(35));
        if (tic.displayObject != null) {
            this.setStyle("icon",tic.imageClass);
            this.labelPlacement = ButtonLabelPlacement.LEFT;
        }
        if (tic.uiTextField != null) {
            this.label = tic.uiTextField.text;
        }
    }
}
</pre>
<p>my problem is when i sort a column. When i click the column header, the data rows are changed  but not sorted&#8230; but i move the mouse cursor over the rows&#8230; magically&#8230; the data in the columns are going to appearing sorted.</p>
<p>any idea?<br />
thanks, congratulations, it´s a great website</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14861</link>
		<author>peterd</author>
		<pubDate>Fri, 22 Aug 2008 14:20:50 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14861</guid>
		<description>janet,

Interesting. I see the same default sort as you (1.32, -12.23, 4.96, -0.94) -- the items are unsorted and appear in the same order they were specified in the data provider.
If I sort by price (descending), I get the following: -12.23, -0.94, 1.32, 4.96 (or Item 2, Item 4, Item 1, Item 3). This sort is correct since the biggest negative values are first and the biggest positive values are last.
If I sort by price (ascending), I get the following: 4.96, 1.32, -0.94, -12.23 (or Item 3, Item 1, Item 4, Item 2). This sort is correct since the biggest positive values are first and the biggest negative values are last.

Actually, are you sure your numbers are right? 0.94 and 12.23 are both negative numbers. So I wouldn't expect the price column to sort as 12.23, 4.96, 1.32, 0.94 since both 0.94 and 12.23 are negative numbers in the data provider. I'd expect 4.96, 1.32, -0.94, -12.23.

Peter</description>
		<content:encoded><![CDATA[<p>janet,</p>
<p>Interesting. I see the same default sort as you (1.32, -12.23, 4.96, -0.94) &#8212; the items are unsorted and appear in the same order they were specified in the data provider.<br />
If I sort by price (descending), I get the following: -12.23, -0.94, 1.32, 4.96 (or Item 2, Item 4, Item 1, Item 3). This sort is correct since the biggest negative values are first and the biggest positive values are last.<br />
If I sort by price (ascending), I get the following: 4.96, 1.32, -0.94, -12.23 (or Item 3, Item 1, Item 4, Item 2). This sort is correct since the biggest positive values are first and the biggest negative values are last.</p>
<p>Actually, are you sure your numbers are right? 0.94 and 12.23 are both negative numbers. So I wouldn&#8217;t expect the price column to sort as 12.23, 4.96, 1.32, 0.94 since both 0.94 and 12.23 are negative numbers in the data provider. I&#8217;d expect 4.96, 1.32, -0.94, -12.23.</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janet</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14847</link>
		<author>janet</author>
		<pubDate>Thu, 21 Aug 2008 19:46:44 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14847</guid>
		<description>Nope, when the prices are loaded you get ($1.32, $12.23, $4.96, $0.94), if you sort the price column you get ($12.23, $0.94, $1.32, $4.96) instead of ($12.23, $4.96, $1.32, $0.94), and if you sort again to get the numbers from descendant to ascendant you have($4.96, $1.32, $0.95, $12.23) instead of ($0.95, $1.32, $4.96, $12.23)...</description>
		<content:encoded><![CDATA[<p>Nope, when the prices are loaded you get ($1.32, $12.23, $4.96, $0.94), if you sort the price column you get ($12.23, $0.94, $1.32, $4.96) instead of ($12.23, $4.96, $1.32, $0.94), and if you sort again to get the numbers from descendant to ascendant you have($4.96, $1.32, $0.95, $12.23) instead of ($0.95, $1.32, $4.96, $12.23)&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14822</link>
		<author>peterd</author>
		<pubDate>Wed, 20 Aug 2008 21:30:38 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14822</guid>
		<description>janet,

The price column is sorting as numbers, isn't it?

Peter</description>
		<content:encoded><![CDATA[<p>janet,</p>
<p>The price column is sorting as numbers, isn&#8217;t it?</p>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: janet</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14820</link>
		<author>janet</author>
		<pubDate>Wed, 20 Aug 2008 20:32:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14820</guid>
		<description>Hi guys,

In this example, how can be sorted the price column as a number?

Any ideas?

Janet</description>
		<content:encoded><![CDATA[<p>Hi guys,</p>
<p>In this example, how can be sorted the price column as a number?</p>
<p>Any ideas?</p>
<p>Janet</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Joshua</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14315</link>
		<author>Joshua</author>
		<pubDate>Wed, 23 Jul 2008 19:41:36 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-14315</guid>
		<description>Note that a similar solution (for background-color) is posted by jlafferty at:
http://butterfliesandbugs.wordpress.com/2007/07/11/using-an-itemrenderer-to-change-the-background-of-a-datagrid-cell/</description>
		<content:encoded><![CDATA[<p>Note that a similar solution (for background-color) is posted by jlafferty at:<br />
<a href="http://butterfliesandbugs.wordpress.com/2007/07/11/using-an-itemrenderer-to-change-the-background-of-a-datagrid-cell/" rel="nofollow">http://butterfliesandbugs.wordpress.com/2007/07/11/using-an-itemrenderer-to-change-the-background-of-a-datagrid-cell/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: marktplaats</title>
		<link>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-13912</link>
		<author>marktplaats</author>
		<pubDate>Fri, 04 Jul 2008 03:36:11 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/08/20/formatting-a-flex-datagrid-control-using-a-custom-item-renderer/#comment-13912</guid>
		<description>Some more great info, thanks for the tips.</description>
		<content:encoded><![CDATA[<p>Some more great info, thanks for the tips.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
