I have a form that consists of two data grids and a button. Datagrid 1, “myStaticDataGrid”, has values I have added for the user to select from. I want the button’s click event to send the current selection of myStaticDataGrid to the second datagrid, “myDataGrid”. I have been able to accomplish this if I use a text box and a datagrid but I am having trouble finding the right syntax to grab the selection data from myStaticDataGrid.
This is my attempt using the two datagrid approach:
<s:Form id="myForm">
//The values from this grid are determined once the button is clicked.
<s:FormItem id="myDataGrid">
<s:DataGrid id="bdgFormData">
<s:typicalItem>
<s:DataItem formData="Description" xmlData="Value"/>
</s:typicalItem>
<s:ArrayCollection id="values"> </s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
//The values from this grid are determined at runtime.
<s:FormItem id="myStaticDataGrid">
<s:DataGrid id="userSelects">
<s:typicalItem>
<s:DataItem selects="Typical Item" codes="0000"/>
</s:typicalItem>
<s:ArrayCollection id="selects">
<s:DataItem selects="Y" codes="1"/>
<s:DataItem selects="N" codes="0"/>
</s:ArrayCollection>
</s:DataGrid>
</s:FormItem>
<s:FormItem label="Add Selects">
<s:Button label="Go" click="addData(event)"/>
</s:FormItem>
My AS event to send the data:
protected function addData(event:MouseEvent):void
{
//Put selected data at the top of the grid.
items.addItemAt(lstFormData.typicalItem,0)
}
My question is where do I bind the grid data?
This is how I send the textbox data to a the datagrid:
<s:FormItem label="myDataUtil">
<s:Label text="Value"/>
<s:TextInput text="@{lstFormData.typicalItem.formData}"/>
</s:FormItem>
I whipped this up for you unfortunately I only have flex 3 here so you will have to make conversions for whatever you need but you should get the idea of how it works.
Here is an example without binding data