<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Stephen Gray&#039;s dev blog &#187; itemEditEnd</title>
	<atom:link href="http://blog.s-gray.com/tag/itemeditend/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.s-gray.com</link>
	<description>e-commerce and integrations</description>
	<lastBuildDate>Sun, 17 Jan 2010 09:32:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flex save changes from an AdvancedDataGrid using itemEditEnd</title>
		<link>http://blog.s-gray.com/2008/09/15/flex-save-changes-from-an-advanceddatagrid-using-itemeditend/</link>
		<comments>http://blog.s-gray.com/2008/09/15/flex-save-changes-from-an-advanceddatagrid-using-itemeditend/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 10:38:22 +0000</pubDate>
		<dc:creator>Stephen</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[advanceddatagrid]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[itemEditEnd]]></category>
		<category><![CDATA[save]]></category>

		<guid isPermaLink="false">http://colourgray.wordpress.com/?p=96</guid>
		<description><![CDATA[Quick tutorial on how to retrieve the value of an edited cell from an AdvancedDataGrid.]]></description>
			<content:encoded><![CDATA[<p>I just remembered that I had trouble finding out what I could access with this event handler function. Sure it was easy to find out when the event is dispatched, but how can I access the new field value edited by the user? How do I access the previous value?</p>
<p>So this is just a simple example showing you that. This also applies to the normal DataGrid and standard list controls.</p>
<p>The itemEditEnd event is dispatched (it&#8217;s in the name) when a user finishes editing a cell so this is pretty much the best time to save the user&#8217;s changes to that field/row.</p>
<p>Here&#8217;s our function:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p96code1'); return false;">View Code</a> ACTIONSCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p961"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code" id="p96code1"><pre class="actionscript" style="font-family:monospace;">protected <span style="color: #000000; font-weight: bold;">function</span> saveChange<span style="color: #66cc66;">&#40;</span>event:AdvancedDataGridEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/**
     * use event.dataField to get the edited field name
     */</span>
    <span style="color: #000000; font-weight: bold;">var</span> field:<span style="color: #0066CC;">String</span> = event.<span style="color: #006600;">dataField</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * i'm using the following line to get the 'id' of the row being edited
     * because i passed an 'id' field through from my dataProvider.
     */</span>
    <span style="color: #000000; font-weight: bold;">var</span> selectedID:<span style="color: #0066CC;">String</span> = event.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">id</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">/**
     * use the itemEditorInstance to get the newly edited value but retrieve
     * the previous value from the existing grid data. i'm using the default
     * textinput itemRenderer so I can retrieve the new value using the 
     * itemEditInstance's 'text' property.
     */</span>
    <span style="color: #000000; font-weight: bold;">var</span> newValue:<span style="color: #0066CC;">String</span> = event.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">itemEditorInstance</span>.<span style="color: #0066CC;">text</span>;
    <span style="color: #000000; font-weight: bold;">var</span> prevValue:<span style="color: #0066CC;">String</span> = ProductPersonalisationList.<span style="color: #006600;">selectedItem</span><span style="color: #66cc66;">&#91;</span>event.<span style="color: #006600;">dataField</span><span style="color: #66cc66;">&#93;</span>;
&nbsp;
    <span style="color: #808080; font-style: italic;">// run a http service call or something to save the change or validate the data</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.s-gray.com/2008/09/15/flex-save-changes-from-an-advanceddatagrid-using-itemeditend/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

