<?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: Creating an editable DataGrid control in Flex</title>
	<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Fri, 21 Nov 2008 05:49:44 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: Stuart Ward</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15246</link>
		<author>Stuart Ward</author>
		<pubDate>Thu, 04 Sep 2008 18:44:16 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15246</guid>
		<description>Peter,
Is is possible to extend this a bit and select text across two or more cells in a given row - still using the typical click and drag highlight method that is used in your examples?

I am aware that the Advanced DataGrid has a multiple select feature, but it relies on conrol-clicking each cell and selected the entire contents of the cell.

Thanks for your help,
Stuart</description>
		<content:encoded><![CDATA[<p>Peter,<br />
Is is possible to extend this a bit and select text across two or more cells in a given row - still using the typical click and drag highlight method that is used in your examples?</p>
<p>I am aware that the Advanced DataGrid has a multiple select feature, but it relies on conrol-clicking each cell and selected the entire contents of the cell.</p>
<p>Thanks for your help,<br />
Stuart</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15192</link>
		<author>peterd</author>
		<pubDate>Wed, 03 Sep 2008 17:56:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15192</guid>
		<description>Another option may be an editable DataGrid with a selectable (and non-editable) item editor:

&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&#62;

    &#60;mx:Array id="arr"&#62;
        &#60;mx:Object c1="One.1" c2="Two.1" c3="Three.1" /&#62;
        &#60;mx:Object c1="One.2" c2="Two.2" c3="Three.2" /&#62;
        &#60;mx:Object c1="One.3" c2="Two.3" c3="Three.3" /&#62;
        &#60;mx:Object c1="One.4" c2="Two.4" c3="Three.4" /&#62;
        &#60;mx:Object c1="One.5" c2="Two.5" c3="Three.5" /&#62;
        &#60;mx:Object c1="One.6" c2="Two.6" c3="Three.6" /&#62;
        &#60;mx:Object c1="One.7" c2="Two.7" c3="Three.7" /&#62;
        &#60;mx:Object c1="One.8" c2="Two.8" c3="Three.8" /&#62;
    &#60;/mx:Array&#62;

    &#60;mx:Component id="dgIR"&#62;
        &#60;mx:DataGridItemRenderer selectable="true" /&#62;
    &#60;/mx:Component&#62;

    &#60;mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            editable="true"&#62;
        &#60;mx:columns&#62;
            &#60;mx:DataGridColumn dataField="c1" editable="false" /&#62;
            &#60;mx:DataGridColumn dataField="c2" itemEditor="{dgIR}" /&#62;
            &#60;mx:DataGridColumn dataField="c3" itemEditor="{dgIR}" /&#62;
        &#60;/mx:columns&#62;
    &#60;/mx:DataGrid&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Peter

Note: Only the last 2 columns in the DataGrid control are editable. Also, you have to click the cell once to bring up the item editor. Another option could be using a TextInput/TextArea control and setting its &lt;code&gt;editable&lt;/code&gt; property to &lt;code&gt;false&lt;/code&gt;.</description>
		<content:encoded><![CDATA[<p>Another option may be an editable DataGrid with a selectable (and non-editable) item editor:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object c1="One.1" c2="Two.1" c3="Three.1" /&gt;
        &lt;mx:Object c1="One.2" c2="Two.2" c3="Three.2" /&gt;
        &lt;mx:Object c1="One.3" c2="Two.3" c3="Three.3" /&gt;
        &lt;mx:Object c1="One.4" c2="Two.4" c3="Three.4" /&gt;
        &lt;mx:Object c1="One.5" c2="Two.5" c3="Three.5" /&gt;
        &lt;mx:Object c1="One.6" c2="Two.6" c3="Three.6" /&gt;
        &lt;mx:Object c1="One.7" c2="Two.7" c3="Three.7" /&gt;
        &lt;mx:Object c1="One.8" c2="Two.8" c3="Three.8" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:Component id="dgIR"&gt;
        &lt;mx:DataGridItemRenderer selectable="true" /&gt;
    &lt;/mx:Component&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            editable="true"&gt;
        &lt;mx:columns&gt;
            &lt;mx:DataGridColumn dataField="c1" editable="false" /&gt;
            &lt;mx:DataGridColumn dataField="c2" itemEditor="{dgIR}" /&gt;
            &lt;mx:DataGridColumn dataField="c3" itemEditor="{dgIR}" /&gt;
        &lt;/mx:columns&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p>Peter</p>
<p>Note: Only the last 2 columns in the DataGrid control are editable. Also, you have to click the cell once to bring up the item editor. Another option could be using a TextInput/TextArea control and setting its <code>editable</code> property to <code>false</code>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15191</link>
		<author>peterd</author>
		<pubDate>Wed, 03 Sep 2008 17:41:00 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15191</guid>
		<description>SD.Plox,

There may be easier/better ways, but you can definitely create a custom item renderer and set the &lt;code&gt;selectable&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt;, as seen in the following example:

&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&#62;

    &#60;mx:Array id="arr"&#62;
        &#60;mx:Object c1="One.1" c2="Two.1" c3="Three.1" /&#62;
        &#60;mx:Object c1="One.2" c2="Two.2" c3="Three.2" /&#62;
        &#60;mx:Object c1="One.3" c2="Two.3" c3="Three.3" /&#62;
        &#60;mx:Object c1="One.4" c2="Two.4" c3="Three.4" /&#62;
        &#60;mx:Object c1="One.5" c2="Two.5" c3="Three.5" /&#62;
        &#60;mx:Object c1="One.6" c2="Two.6" c3="Three.6" /&#62;
        &#60;mx:Object c1="One.7" c2="Two.7" c3="Three.7" /&#62;
        &#60;mx:Object c1="One.8" c2="Two.8" c3="Three.8" /&#62;
    &#60;/mx:Array&#62;

    &#60;mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            editable="false"&#62;
        &#60;mx:itemRenderer&#62;
            &#60;mx:Component&#62;
                &#60;mx:Label selectable="true" /&#62;
            &#60;/mx:Component&#62;
        &#60;/mx:itemRenderer&#62;
    &#60;/mx:DataGrid&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Or, you could also just create a custom item renderer based on the default DataGridItemRenderer and set the &lt;code&gt;selectable&lt;/code&gt; property there instead:
&lt;pre class="code"&gt;
&#60;mx:DataGrid id="dataGrid"
        dataProvider="{arr}"
        editable="false"&#62;
    &#60;mx:itemRenderer&#62;
        &#60;mx:Component&#62;
            &#60;mx:DataGridItemRenderer selectable="true" /&#62;
        &#60;/mx:Component&#62;
    &#60;/mx:itemRenderer&#62;
&#60;/mx:DataGrid&#62;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p>SD.Plox,</p>
<p>There may be easier/better ways, but you can definitely create a custom item renderer and set the <code>selectable</code> property to <code>true</code>, as seen in the following example:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object c1="One.1" c2="Two.1" c3="Three.1" /&gt;
        &lt;mx:Object c1="One.2" c2="Two.2" c3="Three.2" /&gt;
        &lt;mx:Object c1="One.3" c2="Two.3" c3="Three.3" /&gt;
        &lt;mx:Object c1="One.4" c2="Two.4" c3="Three.4" /&gt;
        &lt;mx:Object c1="One.5" c2="Two.5" c3="Three.5" /&gt;
        &lt;mx:Object c1="One.6" c2="Two.6" c3="Three.6" /&gt;
        &lt;mx:Object c1="One.7" c2="Two.7" c3="Three.7" /&gt;
        &lt;mx:Object c1="One.8" c2="Two.8" c3="Three.8" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:DataGrid id="dataGrid"
            dataProvider="{arr}"
            editable="false"&gt;
        &lt;mx:itemRenderer&gt;
            &lt;mx:Component&gt;
                &lt;mx:Label selectable="true" /&gt;
            &lt;/mx:Component&gt;
        &lt;/mx:itemRenderer&gt;
    &lt;/mx:DataGrid&gt;

&lt;/mx:Application&gt;
</pre>
<p>Or, you could also just create a custom item renderer based on the default DataGridItemRenderer and set the <code>selectable</code> property there instead:</p>
<pre class="code">
&lt;mx:DataGrid id="dataGrid"
        dataProvider="{arr}"
        editable="false"&gt;
    &lt;mx:itemRenderer&gt;
        &lt;mx:Component&gt;
            &lt;mx:DataGridItemRenderer selectable="true" /&gt;
        &lt;/mx:Component&gt;
    &lt;/mx:itemRenderer&gt;
&lt;/mx:DataGrid&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SD.Plox</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15186</link>
		<author>SD.Plox</author>
		<pubDate>Wed, 03 Sep 2008 16:03:31 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15186</guid>
		<description>Hi Guys,

our team is trying to perform text selection on datagrid cells, but we haven't found a property, (selectable isn't) an method, or a flex facility for this task...

is a renderer necessary for this case?

best regards,

SD.Plox</description>
		<content:encoded><![CDATA[<p>Hi Guys,</p>
<p>our team is trying to perform text selection on datagrid cells, but we haven&#8217;t found a property, (selectable isn&#8217;t) an method, or a flex facility for this task&#8230;</p>
<p>is a renderer necessary for this case?</p>
<p>best regards,</p>
<p>SD.Plox</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bhargavi</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15022</link>
		<author>bhargavi</author>
		<pubDate>Fri, 29 Aug 2008 14:05:23 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-15022</guid>
		<description>hi i want one thing is that after editing the cell value of data grid , i want that changed cell value.please anybody can help me.</description>
		<content:encoded><![CDATA[<p>hi i want one thing is that after editing the cell value of data grid , i want that changed cell value.please anybody can help me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex C</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-14949</link>
		<author>Alex C</author>
		<pubDate>Tue, 26 Aug 2008 14:51:51 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-14949</guid>
		<description>Hi. Is there an example of how to do paging on a Flex datagrid? This way you only show a certain number of records per page and have Next/Previous buttons to let the user view more pages of records or jump to a specific page.</description>
		<content:encoded><![CDATA[<p>Hi. Is there an example of how to do paging on a Flex datagrid? This way you only show a certain number of records per page and have Next/Previous buttons to let the user view more pages of records or jump to a specific page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brent</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13064</link>
		<author>Brent</author>
		<pubDate>Wed, 28 May 2008 23:25:13 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13064</guid>
		<description>Opps forgot the renderer above.
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.controls.listClasses.IDropInListItemRenderer"
horizontalAlign="center"
verticalScrollPolicy="off" horizontalScrollPolicy="off"
preinitialize="init()"&#62;
&#60;mx:Label id="CellText" width="93%" paddingLeft="20" /&#62;
&#60;mx:Label textAlign="right" text="+" toolTip="Edit" width="12" styleName="editPlusSign" /&#62;
&#60;mx:Script&#62;
&#60;![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import mx.controls.DataGrid;

private var iListData:BaseListData;

/**
 * Implement listData getter from IDropInListItemRenderer
 */
public function get listData():BaseListData 
{
  return iListData;
}

/**
 * Implement listData setter from IDropInListItemRenderer
 */
public function set listData( value:BaseListData ):void 
{
    iListData = value;
} 
   
/**
* Add event listener for when data changes
*/
private function init():void 
{
    addEventListener("dataChange", handleDataChanged);
}    

/**
 * When data changes update the cell text based on the dataField
 */
private function handleDataChanged(event:Event):void 
{
    // Cast listData to DataGridListData.
    var myListData:DataGridListData = DataGridListData(listData);
    CellText.text = data[myListData.dataField];

}
]]&#62;
&#60;/mx:Script&#62;
&#60;/mx:HBox&#62;
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>Opps forgot the renderer above.</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
implements="mx.controls.listClasses.IDropInListItemRenderer"
horizontalAlign="center"
verticalScrollPolicy="off" horizontalScrollPolicy="off"
preinitialize="init()"&gt;
&lt;mx:Label id="CellText" width="93%" paddingLeft="20" /&gt;
&lt;mx:Label textAlign="right" text="+" toolTip="Edit" width="12" styleName="editPlusSign" /&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
import mx.controls.dataGridClasses.DataGridListData;
import mx.controls.listClasses.BaseListData;
import mx.controls.DataGrid;

private var iListData:BaseListData;

/**
 * Implement listData getter from IDropInListItemRenderer
 */
public function get listData():BaseListData
{
  return iListData;
}

/**
 * Implement listData setter from IDropInListItemRenderer
 */
public function set listData( value:BaseListData ):void
{
    iListData = value;
} 

/**
* Add event listener for when data changes
*/
private function init():void
{
    addEventListener("dataChange", handleDataChanged);
}    

/**
 * When data changes update the cell text based on the dataField
 */
private function handleDataChanged(event:Event):void
{
    // Cast listData to DataGridListData.
    var myListData:DataGridListData = DataGridListData(listData);
    CellText.text = data[myListData.dataField];

}
]]&gt;
&lt;/mx:Script&gt;
&lt;/mx:HBox&gt;
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brent</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13062</link>
		<author>Brent</author>
		<pubDate>Wed, 28 May 2008 20:41:30 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13062</guid>
		<description>Yeah yeah check this out.  Dig this, Johnson !!

Here's your dataGrid code:
&lt;pre class="code"&gt;
&#60;mx:DataGridColumn headerText="Quantity" dataField="Quantity" textAlign="center" itemRenderer="path.to.your.view.EditableCellRenderer"
itemEditor="path.to.your.view.EditableCellEditor" /&#62;	
&lt;/pre&gt;

And here's your editable cell editor:
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml" 
	width="100%" height="100%"
	restrict="0-9"&#62;
	
	&#60;mx:Script&#62;
		&#60;![CDATA[
			import mx.controls.DataGrid;
			
			/**
			 * Override data setter to set cell text according to the dataField
			 */
			public override function set data(value:Object):void
			{
				var dg:DataGrid = owner as DataGrid;
				text = value[dg.columns[dg.editedItemPosition.columnIndex].dataField];
			}
		]]&#62;
	&#60;/mx:Script&#62;
&#60;/mx:TextInput&#62;
&lt;/pre&gt;

This is even better since you don't need to know which order your dataGrid column is and cuts your code by like 90%.</description>
		<content:encoded><![CDATA[<p>Yeah yeah check this out.  Dig this, Johnson !!</p>
<p>Here&#8217;s your dataGrid code:</p>
<pre class="code">
&lt;mx:DataGridColumn headerText="Quantity" dataField="Quantity" textAlign="center" itemRenderer="path.to.your.view.EditableCellRenderer"
itemEditor="path.to.your.view.EditableCellEditor" /&gt;
</pre>
<p>And here&#8217;s your editable cell editor:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml"
	width="100%" height="100%"
	restrict="0-9"&gt;

	&lt;mx:Script&gt;
		&lt;![CDATA[
			import mx.controls.DataGrid;

			/**
			 * Override data setter to set cell text according to the dataField
			 */
			public override function set data(value:Object):void
			{
				var dg:DataGrid = owner as DataGrid;
				text = value[dg.columns[dg.editedItemPosition.columnIndex].dataField];
			}
		]]&gt;
	&lt;/mx:Script&gt;
&lt;/mx:TextInput&gt;
</pre>
<p>This is even better since you don&#8217;t need to know which order your dataGrid column is and cuts your code by like 90%.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashanth Samanth</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13016</link>
		<author>Prashanth Samanth</author>
		<pubDate>Tue, 27 May 2008 11:18:56 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13016</guid>
		<description>Peted,

File uploads and Downloads I got this and implemented, please have look at this 
http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_9.html,

thought it will help you too

PSamanth</description>
		<content:encoded><![CDATA[<p>Peted,</p>
<p>File uploads and Downloads I got this and implemented, please have look at this<br />
<a href="http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_9.html," rel="nofollow">http://livedocs.adobe.com/flex/3/html/help.html?content=17_Networking_and_communications_9.html,</a></p>
<p>thought it will help you too</p>
<p>PSamanth</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prashanth Samanth</title>
		<link>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13015</link>
		<author>Prashanth Samanth</author>
		<pubDate>Tue, 27 May 2008 10:58:44 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2008/05/11/creating-an-editable-datagrid-control-in-flex/#comment-13015</guid>
		<description>Peterd,

I even want a Text input before the Browse, so that the User can directly type the path he want to upload... 

PSamanth</description>
		<content:encoded><![CDATA[<p>Peterd,</p>
<p>I even want a Text input before the Browse, so that the User can directly type the path he want to upload&#8230; </p>
<p>PSamanth</p>
]]></content:encoded>
	</item>
</channel>
</rss>
