<?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"
	>
<channel>
	<title>Comments on: Another Flex Weirdness/Gotcha</title>
	<atom:link href="http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/</link>
	<description>Thoughts, rants, and even some code from the mind of Barney Boisvert.</description>
	<pubDate>Thu, 20 Nov 2008 15:08:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Garnet</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-111461</link>
		<dc:creator>Garnet</dc:creator>
		<pubDate>Thu, 31 Jul 2008 23:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-111461</guid>
		<description>I agree about weirdness. It's easy to do cool stuff in Flex quickly, but then you run into a quirk that takes way too long to solve. 

I have this as the data provider for my AdvancedDataGrid: 
        private var dpList:ArrayCollection = new ArrayCollection([
              {Ref:true, Name:"Garnet", 
                  ReadTime:400}]);

In timer routines I want to 
   dpList[0].ReadTime++

But the grid won't update. I tried all of these, and none of them work to cause an update:
              dpList.refresh();
              adgList.validateNow();
              adgList.executeBindings(false);
 
The one thing that does work is doing 
              dpList.addItem(...)

Guess I need to trace into the source for addItem and figure out what it is doing.</description>
		<content:encoded><![CDATA[<p>I agree about weirdness. It's easy to do cool stuff in Flex quickly, but then you run into a quirk that takes way too long to solve. </p>
<p>I have this as the data provider for my AdvancedDataGrid:<br />
        private var dpList:ArrayCollection = new ArrayCollection([<br />
              {Ref:true, Name:"Garnet",<br />
                  ReadTime:400}]);</p>
<p>In timer routines I want to<br />
   dpList[0].ReadTime++</p>
<p>But the grid won't update. I tried all of these, and none of them work to cause an update:<br />
              dpList.refresh();<br />
              adgList.validateNow();<br />
              adgList.executeBindings(false);</p>
<p>The one thing that does work is doing<br />
              dpList.addItem(&#8230;)</p>
<p>Guess I need to trace into the source for addItem and figure out what it is doing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Henry</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-70915</link>
		<dc:creator>William Henry</dc:creator>
		<pubDate>Thu, 03 Apr 2008 23:01:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-70915</guid>
		<description>You can use myDataGrid.executeBindings(false);
The argument determines whether there is recursion.</description>
		<content:encoded><![CDATA[<p>You can use myDataGrid.executeBindings(false);<br />
The argument determines whether there is recursion.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: barneyb</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22227</link>
		<dc:creator>barneyb</dc:creator>
		<pubDate>Sun, 24 Jun 2007 16:07:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22227</guid>
		<description>Thanks for the comments.  I'm aware of how to make it work, I'm just surprised it doesn't work by default.  I.e. there aren't per-property watchers, just per-object watchers.  Refreshing the provider, reexecuting bindings, putting ChangeWatchers on the properties manually, etc., would al work, but it just seems weird to have to do that manually.

I haven't tried it, but I'd be willing to bet that a custom itemRenderer that manually binds itself to the specific property (but is otherwise a "normal" renderer) would fix the issue.  Then you could just use that in all your DataGrids and have it taken care of "automatically".</description>
		<content:encoded><![CDATA[<p>Thanks for the comments.  I'm aware of how to make it work, I'm just surprised it doesn't work by default.  I.e. there aren't per-property watchers, just per-object watchers.  Refreshing the provider, reexecuting bindings, putting ChangeWatchers on the properties manually, etc., would al work, but it just seems weird to have to do that manually.</p>
<p>I haven't tried it, but I'd be willing to bet that a custom itemRenderer that manually binds itself to the specific property (but is otherwise a "normal" renderer) would fix the issue.  Then you could just use that in all your DataGrids and have it taken care of "automatically".</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JesterXL</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22222</link>
		<dc:creator>JesterXL</dc:creator>
		<pubDate>Sun, 24 Jun 2007 15:28:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22222</guid>
		<description>You have a lot more options.

1.

[Bindable]
PersonVO
{
   public var firstName:String;
   public var lastName:String;
   public var address:AddressVO;
}

Using an ArrayCollection that's full of PersonVO's, your DataGrid would have each column bound to 1 of the properties.  In this case, it's assumed that your AddressVO has a toString() method to return a nicely formatted Address string.

2. Use a label function.  When a variable changes on your VO, your label function will run and you can format it how you wish.

3. Use an itemRenderer.  While it's implied you are building the itemRenderer per column, you basically get your data function which is fed the object from the ArrayCollection, so you don't necessarely have to use the column name in question.

In all scenarios above, if you change the "firstName" property, the field will update in the DataGrid (whether on its own, via your labelFunction getting called again, or your itemRenderer's data setter getting run).  If it's not, you are either not using the Bindable tag up top, or not strongly typing your variables.</description>
		<content:encoded><![CDATA[<p>You have a lot more options.</p>
<p>1.</p>
<p>[Bindable]<br />
PersonVO<br />
{<br />
   public var firstName:String;<br />
   public var lastName:String;<br />
   public var address:AddressVO;<br />
}</p>
<p>Using an ArrayCollection that's full of PersonVO's, your DataGrid would have each column bound to 1 of the properties.  In this case, it's assumed that your AddressVO has a toString() method to return a nicely formatted Address string.</p>
<p>2. Use a label function.  When a variable changes on your VO, your label function will run and you can format it how you wish.</p>
<p>3. Use an itemRenderer.  While it's implied you are building the itemRenderer per column, you basically get your data function which is fed the object from the ArrayCollection, so you don't necessarely have to use the column name in question.</p>
<p>In all scenarios above, if you change the "firstName" property, the field will update in the DataGrid (whether on its own, via your labelFunction getting called again, or your itemRenderer's data setter getting run).  If it's not, you are either not using the Bindable tag up top, or not strongly typing your variables.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon Ellis</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22142</link>
		<dc:creator>Brandon Ellis</dc:creator>
		<pubDate>Sun, 24 Jun 2007 03:13:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22142</guid>
		<description>Hi,
Instead of sorting the rows, you should be able to call ArrayCollection.refresh(); and that will trigger an update.

I'm doing that in an app of mine. :)</description>
		<content:encoded><![CDATA[<p>Hi,<br />
Instead of sorting the rows, you should be able to call ArrayCollection.refresh(); and that will trigger an update.</p>
<p>I'm doing that in an app of mine. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shaun</title>
		<link>http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22131</link>
		<dc:creator>shaun</dc:creator>
		<pubDate>Sun, 24 Jun 2007 01:45:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.barneyb.com/barneyblog/2007/06/23/another-flex-weirdnessgotcha/#comment-22131</guid>
		<description>I think I call grid.dataProvider.refresh from a custom event handler when i've completed updating the dataprovider.

HTH</description>
		<content:encoded><![CDATA[<p>I think I call grid.dataProvider.refresh from a custom event handler when i've completed updating the dataprovider.</p>
<p>HTH</p>
]]></content:encoded>
	</item>
</channel>
</rss>
