enter and save data in a table.

hi guys

I have a requirment where i want the users to enter data in a table. I should be able to store that data in an array (or an arraylist or any collection) and pass it to the backend.
Any idea how i can do that?

Thanks.
royjaydAsked:
Who is Participating?
 
dgofmanCommented:
Try this code:

	<fx:Script>
		<![CDATA[
			import mx.events.DataGridEvent;
			import mx.events.FlexEvent;

			[Bindable]
			private var rows:Array = [	{col1:11, col2:12, col3:13},
										{col1:21, col2:22, col3:23},
										{col1:31, col2:32, col3:33},
										{col1:41, col2:42, col3:43}];

			private var modifiedData:Object = {};

			protected function datagrid1_initializeHandler(event:FlexEvent):void{
				event.target.addEventListener(DataGridEvent.ITEM_EDIT_END, onColumnChanged);
			}

			protected function onColumnChanged(event:DataGridEvent):void{
				if(modifiedData[event.rowIndex] == undefined)
					modifiedData[event.rowIndex] = {};
				var data:Object = dg.itemEditorInstance[dg.columns[event.columnIndex].editorDataField];
				modifiedData[event.rowIndex][event.dataField] = data;
			}
		]]>
	</fx:Script>
	<mx:DataGrid id="dg" dataProvider="{rows}" editable="true" initialize="datagrid1_initializeHandler(event)">
		<mx:columns>
			<mx:DataGridColumn dataField="col1"/>
			<mx:DataGridColumn dataField="col2"/>
			<mx:DataGridColumn dataField="col3"/>
		</mx:columns>
	</mx:DataGrid>

Open in new window

0
 
royjaydAuthor Commented:
thanks, works for me.
Any help with my next question will be greatly appreciated
Its related to the expand-collapse functionality which you helped me with before but slightly different.

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Flex/Q_26934767.html

thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.