<?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>Flex Examples &#187; itemEditBegin</title>
	<atom:link href="http://blog.flexexamples.com/tag/itemeditbegin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Creating an editable DataGrid control in Flex</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comments</comments>
		<pubDate>Mon, 12 May 2008 02:50:28 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DataGridColumn]]></category>
		<category><![CDATA[editable]]></category>
		<category><![CDATA[itemEditBegin]]></category>
		<category><![CDATA[itemEditBeginning]]></category>
		<category><![CDATA[itemEditEnd]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can create an editable Flex DataGrid control by setting the editable property on the DataGrid and DataGridColumn objects.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_editable_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:ArrayCollection id="arrColl"&#62; &#60;mx:source&#62; &#60;mx:Array&#62; &#60;mx:Object label="Student A" score="85" /&#62; &#60;mx:Object [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create an editable Flex DataGrid control by setting the <code>editable</code> property on the DataGrid and DataGridColumn objects.</p>
<p>Full code after the jump.</p>
<p><span id="more-626"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_editable_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;
        &lt;mx:source&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object label="Student A" score="85" /&gt;
                &lt;mx:Object label="Student B" score="48" /&gt;
                &lt;mx:Object label="Student C" score="71" /&gt;
                &lt;mx:Object label="Student D" score="88" /&gt;
                &lt;mx:Object label="Student E" score="24" /&gt;
                &lt;mx:Object label="Student F" score="64" /&gt;
                &lt;mx:Object label="Student G" score="76" /&gt;
                &lt;mx:Object label="Student H" score="76" /&gt;
                &lt;mx:Object label="Student I" score="93" /&gt;
                &lt;mx:Object label="Student J" score="88" /&gt;
                &lt;mx:Object label="Student K" score="48" /&gt;
                &lt;mx:Object label="Student L" score="76" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:source&gt;
    &lt;/mx:ArrayCollection&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            editable="true"
            rowCount="8"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="label"
                    editable="false" /&gt;
            &lt;mx:DataGridColumn dataField="score"
                    editable="true" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_editable_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_editable_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>When working with editable DataGrid controls, there are three events which can be useful: <code>itemEditBeginning</code>, <code>itemEditBegin</code>, and <code>itemEditEnd</code>.</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_itemEditBeginning_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.DataGridEvent;

            private function addEvent(evt:DataGridEvent):void {
                eventsArrColl.addItem(evt);
            }

            private function clearEvents():void {
                eventsArrColl = new ArrayCollection();
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;
        &lt;mx:source&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object label="Student A" score="85" /&gt;
                &lt;mx:Object label="Student B" score="48" /&gt;
                &lt;mx:Object label="Student C" score="71" /&gt;
                &lt;mx:Object label="Student D" score="88" /&gt;
                &lt;mx:Object label="Student E" score="24" /&gt;
                &lt;mx:Object label="Student F" score="64" /&gt;
                &lt;mx:Object label="Student G" score="76" /&gt;
                &lt;mx:Object label="Student H" score="76" /&gt;
                &lt;mx:Object label="Student I" score="93" /&gt;
                &lt;mx:Object label="Student J" score="88" /&gt;
                &lt;mx:Object label="Student K" score="48" /&gt;
                &lt;mx:Object label="Student L" score="76" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:source&gt;
    &lt;/mx:ArrayCollection&gt;

    &lt;mx:ArrayCollection id="eventsArrColl" /&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button label="Clear DataGrid" click="clearEvents();" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arrColl}"
            editable="true"
            rowCount="8"
            itemEditBegin="addEvent(event);"
            itemEditBeginning="addEvent(event);"
            itemEditEnd="addEvent(event);"
            itemFocusIn="//addEvent(event);"
            itemFocusOut="//addEvent(event);"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="label"
                    editable="false" /&gt;
            &lt;mx:DataGridColumn dataField="score"
                    editable="true" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

    &lt;mx:DataGrid id="eventsDataGrid"
            dataProvider="{eventsArrColl}"
            itemRenderer="mx.controls.Label"
            verticalScrollPolicy="on"
            rowCount="9"
            width="100%"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="columnIndex" /&gt;
            &lt;mx:DataGridColumn dataField="dataField" /&gt;
            &lt;mx:DataGridColumn dataField="itemRenderer" /&gt;
            &lt;mx:DataGridColumn dataField="reason" /&gt;
            &lt;mx:DataGridColumn dataField="rowIndex" /&gt;
            &lt;mx:DataGridColumn dataField="type" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/DataGrid_itemEditBeginning_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/DataGrid_itemEditBeginning_test/bin/main.html" width="100%" height="520"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating an editable DataGrid control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/',contentID: 'post-626',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'editable,itemEditBegin,itemEditBeginning,itemEditEnd',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
	</channel>
</rss>

