<?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: Handling data updates with the Flex AS3 DataGrid</title>
	<atom:link href="http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/</link>
	<description>Custom Software</description>
	<lastBuildDate>Fri, 10 Feb 2012 20:13:26 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Jason</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-2010</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 09 Feb 2011 08:19:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-2010</guid>
		<description>crap! i moved servers a while back and stupidly deleted once i thought everything was transferred (which it obviously wasn&#039;t)  I&#039;ll try to find the code but the gist of it is just to add a listener to your collection (ie the data provider) instead of the grid.

Then when you edit the grid it causes collection change events to fire - you don&#039;t even have a listener on the grid, which is kinda cool.

However I don&#039;t think this is a really common approach and as such Adobe doesn&#039;t give it any attention.  it seems to have some glitches, so just be warned.</description>
		<content:encoded><![CDATA[<p>crap! i moved servers a while back and stupidly deleted once i thought everything was transferred (which it obviously wasn&#8217;t)  I&#8217;ll try to find the code but the gist of it is just to add a listener to your collection (ie the data provider) instead of the grid.</p>
<p>Then when you edit the grid it causes collection change events to fire &#8211; you don&#8217;t even have a listener on the grid, which is kinda cool.</p>
<p>However I don&#8217;t think this is a really common approach and as such Adobe doesn&#8217;t give it any attention.  it seems to have some glitches, so just be warned.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-1944</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Sat, 29 Jan 2011 17:47:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-1944</guid>
		<description>I can not download, the link may be gone.</description>
		<content:encoded><![CDATA[<p>I can not download, the link may be gone.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shane</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-597</link>
		<dc:creator>Shane</dc:creator>
		<pubDate>Tue, 24 Nov 2009 01:05:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-597</guid>
		<description>&lt;blockquote cite=&quot;#commentbody-70138&quot;&gt;
&lt;strong&gt;&lt;a href=&quot;#comment-70138&quot; rel=&quot;nofollow&quot;&gt;Jason&lt;/a&gt; :&lt;/strong&gt;
          Another thing to mention is that the change event seems to get thrown multiple times under different circumstances.  If your data class is marked as [Bindable] (for example the Widget class) then the PropertyChangeEvent will contain oldValue and newValue.  If not, they will both be null.  Also the event gets fired twice, the 2nd time oldValue and newValue are null.
One glitch I’ve noticed is that if you sort by a column, then edit the values in that column, you’ll get inconsistent firing of the change event.
         &lt;/blockquote&gt;

This was a huge help to me. I definitely favor monitoring the data model over the view. Does anyone know why the collection change event fires twice? Are people just ignoring propertyChangeEvents with null oldValue and newValue?</description>
		<content:encoded><![CDATA[<blockquote cite="#commentbody-70138"><p>
<strong><a href="#comment-70138" rel="nofollow">Jason</a> :</strong><br />
          Another thing to mention is that the change event seems to get thrown multiple times under different circumstances.  If your data class is marked as [Bindable] (for example the Widget class) then the PropertyChangeEvent will contain oldValue and newValue.  If not, they will both be null.  Also the event gets fired twice, the 2nd time oldValue and newValue are null.<br />
One glitch I’ve noticed is that if you sort by a column, then edit the values in that column, you’ll get inconsistent firing of the change event.
         </p></blockquote>
<p>This was a huge help to me. I definitely favor monitoring the data model over the view. Does anyone know why the collection change event fires twice? Are people just ignoring propertyChangeEvents with null oldValue and newValue?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-596</link>
		<dc:creator>Chris</dc:creator>
		<pubDate>Mon, 21 Sep 2009 11:53:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-596</guid>
		<description>The &quot;dataChange&quot; event works great for me.</description>
		<content:encoded><![CDATA[<p>The &#8220;dataChange&#8221; event works great for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-595</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Sun, 09 Nov 2008 18:24:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-595</guid>
		<description>Thanks for the comment Jesse - yea, itemEndEdit is what you see explained everywhere. I&#039;m wondering if you have a personal reason for doing it that way?  (I really mean that as an honest question, not as a challenge of some sort.)

Adding a listener to the collection has some odd behavior and I still question whether it&#039;s the best way. But the reason I don&#039;t like itemEndEdit is because you have to write a lot of code in the view - particularly in your event handler, you have to write some kind of switch statement to deal with all the columns unless they are all TextInput.

If you have all TextInput fields then its pretty easy but if you have a more typical grid with checkboxes, date fields, dropdowns, maybe some custom item renderers, then you have to know exactly what input control to expect and then cast the correct one in order to get the value.  I don&#039;t really like having to handle each column in the grid differently.

If you listen to the collection changes, on the other hand, the oldValue and newValue get passed to your already cast correctly and you don&#039;t have to even know what type of input control was used to trigger the edit.  I like dealing with things generically when I can so I don&#039;t have to write a bunch of logic in the view layer.

Basically I think it&#039;s a question of whether you want a smart view &amp; dumb model, or a smart model &amp; a dumb view.  I&#039;m taking the approach of a smart model because I&#039;m lazy and I don&#039;t like writing the same event handler code 10 times for the same data just because it appears in several places in the app.

I&#039;d definitely be interested to hear what results people have gotten either way.</description>
		<content:encoded><![CDATA[<p>Thanks for the comment Jesse &#8211; yea, itemEndEdit is what you see explained everywhere. I&#8217;m wondering if you have a personal reason for doing it that way?  (I really mean that as an honest question, not as a challenge of some sort.)</p>
<p>Adding a listener to the collection has some odd behavior and I still question whether it&#8217;s the best way. But the reason I don&#8217;t like itemEndEdit is because you have to write a lot of code in the view &#8211; particularly in your event handler, you have to write some kind of switch statement to deal with all the columns unless they are all TextInput.</p>
<p>If you have all TextInput fields then its pretty easy but if you have a more typical grid with checkboxes, date fields, dropdowns, maybe some custom item renderers, then you have to know exactly what input control to expect and then cast the correct one in order to get the value.  I don&#8217;t really like having to handle each column in the grid differently.</p>
<p>If you listen to the collection changes, on the other hand, the oldValue and newValue get passed to your already cast correctly and you don&#8217;t have to even know what type of input control was used to trigger the edit.  I like dealing with things generically when I can so I don&#8217;t have to write a bunch of logic in the view layer.</p>
<p>Basically I think it&#8217;s a question of whether you want a smart view &amp; dumb model, or a smart model &amp; a dumb view.  I&#8217;m taking the approach of a smart model because I&#8217;m lazy and I don&#8217;t like writing the same event handler code 10 times for the same data just because it appears in several places in the app.</p>
<p>I&#8217;d definitely be interested to hear what results people have gotten either way.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-594</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Sat, 08 Nov 2008 01:48:06 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-594</guid>
		<description>The Flex 3 Cookbook from O&#039;Reilly has a number of good examples on how to use itemEndEdit.</description>
		<content:encoded><![CDATA[<p>The Flex 3 Cookbook from O&#8217;Reilly has a number of good examples on how to use itemEndEdit.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-593</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Sat, 08 Nov 2008 01:46:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-593</guid>
		<description>&quot;You can listen to the itemEndEdit event, unfortunately itemEditEnd is fired before any of the controls or dataProvider are updated. You have access to the original cell value, but the newly entered value is difficult to obtain.&quot;

I would recommend using itemEndEdit. The newly entered value is not difficult to get.

To get the new value use: event.currentTarget.itemEditorInstance

For example:
// This assumes that you&#039;re using the default
// itemEditor which is a TextInput.
newValue:String = TextInput(event.currentTarget.itemEditorInstance).text</description>
		<content:encoded><![CDATA[<p>&#8220;You can listen to the itemEndEdit event, unfortunately itemEditEnd is fired before any of the controls or dataProvider are updated. You have access to the original cell value, but the newly entered value is difficult to obtain.&#8221;</p>
<p>I would recommend using itemEndEdit. The newly entered value is not difficult to get.</p>
<p>To get the new value use: event.currentTarget.itemEditorInstance</p>
<p>For example:<br />
// This assumes that you&#8217;re using the default<br />
// itemEditor which is a TextInput.<br />
newValue:String = TextInput(event.currentTarget.itemEditorInstance).text</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-592</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 16 Sep 2008 20:32:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-592</guid>
		<description>Another thing to mention is that the change event seems to get thrown multiple times under different circumstances.  If your data class is marked as [Bindable] (for example the Widget class) then the PropertyChangeEvent will contain oldValue and newValue.  If not, they will both be null.  Also the event gets fired twice, the 2nd time oldValue and newValue are null.

One glitch I&#039;ve noticed is that if you sort by a column, then edit the values in that column, you&#039;ll get inconsistent firing of the change event.</description>
		<content:encoded><![CDATA[<p>Another thing to mention is that the change event seems to get thrown multiple times under different circumstances.  If your data class is marked as [Bindable] (for example the Widget class) then the PropertyChangeEvent will contain oldValue and newValue.  If not, they will both be null.  Also the event gets fired twice, the 2nd time oldValue and newValue are null.</p>
<p>One glitch I&#8217;ve noticed is that if you sort by a column, then edit the values in that column, you&#8217;ll get inconsistent firing of the change event.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://verysimple.com/2008/09/10/handling-data-updates-with-the-flex-as3-datagrid/#comment-591</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Tue, 16 Sep 2008 19:34:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.verysimple.com/blog/?p=180#comment-591</guid>
		<description>One comment, in my source comments I mention that setting the &quot;source&quot; property doesn&#039;t cause the change event to fire.  Actually the change event does fire but the kind property is &quot;reset&quot; so it is ignored in this sample code.  I&#039;m too lazy to update the zip, but I wanted to clear that up.</description>
		<content:encoded><![CDATA[<p>One comment, in my source comments I mention that setting the &#8220;source&#8221; property doesn&#8217;t cause the change event to fire.  Actually the change event does fire but the kind property is &#8220;reset&#8221; so it is ignored in this sample code.  I&#8217;m too lazy to update the zip, but I wanted to clear that up.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

