este es el codigo de mi pagina central donde esta mi datagrid y el otro codigo es donde esta mi formulario modificar que lo llamo atravez de popup.
Código Flex :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:pruebasflash1service="services.pruebasflash1service.*">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.containers.TitleWindow;
import mx.controls.Alert;
import mx.core.IFlexDisplayObject;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.events.ItemClickEvent;
import mx.managers.PopUpManager;
import spark.components.ComboBox;
protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
{
getAllPruebas_flash1Result.token = pruebasflash1Service.getAllPruebas_flash1();
}
//Variables para busqueda
//funcion busqueda
private var firstTime:Boolean = true;
private function filter():void {
getAllPruebas_flash1Result.lastResult.filterFunction = filterMyArrayCollection;
getAllPruebas_flash1Result.lastResult.refresh();
}
private function filterMyArrayCollection(item:Object):Boolean {
var searchString:String = busqueda.text.toLowerCase();
var itemName:String = (item.nombre as String).toLowerCase();
return itemName.indexOf(searchString) > -1;
}
//dentro de busqueda input clear valor defecto "serach...."
private function clearMyTextInput():void {
if (firstTime == true )
{
busqueda.text = "";
firstTime = false;
}
}
//Fin funcion busqueda
//popup agregar
protected function button1_clickHandler(event:MouseEvent):void
{
/* currentState = "uno";
PopUpManager.addPopUp(olas, this, true);
PopUpManager.centerPopUp(olas);
*/
var sexo:ingresar=new ingresar();
PopUpManager.addPopUp(sexo, this, true);
PopUpManager.centerPopUp(sexo);
// agrega.addEventListener(CloseEvent.CLOSE, titleWindow_close);
}
/*private function titleWindow_close(evt:CloseEvent):void {
PopUpManager.removePopUp(this);
}*/
//FIN POPUP AGREGAR
//variables del modificar
public var editNameWindow:IFlexDisplayObject;
public var myPopUp:modificar;
public function showPopUp(event:MouseEvent):void{
// show the popup
editNameWindow=PopUpManager.createPopUp(this, modificar, true);
// cast to a nameEditorPopup
myPopUp = modificar(editNameWindow);
// pass the popUp my DataGrid Item
myPopUp.DataGridName=dataGrid.selectedItem;
// myPopUp=getAllPruebas_flashResult.lastResult ;
myPopUp.DataGridNameAC=getAllPruebas_flash1Result.lastResult;
// select('1');
}
/*#########################################################################
Fin Modificar
*/
/* public function select(key:String):void{
for (var i:int=0; i< .length; i++) {
var item:String = SexoService[i];
if(item == key) {
combo.comboBox.selectedIndex = i;
break;
}
}
}
*/
]]>
</fx:Script>
<fx:Declarations>
<s:CallResponder id="getAllPruebas_flash1Result"/>
<pruebasflash1service:Pruebasflash1Service id="pruebasflash1Service" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:DataGrid x="61" y="90" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllPruebas_flash1Result.lastResult}">
<mx:columns>
<mx:DataGridColumn headerText="codigo" dataField="codigo"/>
<mx:DataGridColumn headerText="nombre" dataField="nombre"/>
<mx:DataGridColumn headerText="apellido" dataField="apellido"/>
<mx:DataGridColumn headerText="sexo" dataField="sexo"/>
</mx:columns>
</mx:DataGrid>
<s:TextInput x="61" y="45" width="176" id="busqueda" change="filter()" focusIn="clearMyTextInput()" text="Buscar/nombre" enabled="true"/>
<s:Button x="262" y="46" label="Buscar"/>
<s:Button x="61" y="272" label="Ingresar" click="button1_clickHandler(event)"/>
<s:Button x="139" y="272" label="Modificar" click="showPopUp(event)"/>
<s:Button x="217" y="272" label="Eliminar"/>
</s:Application>
Código Flex :
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="358" height="300" xmlns:valueObjects="valueObjects.*" xmlns:sexoservice="services.sexoservice.*">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.containers.TitleWindow;
import mx.controls.Alert;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
[Bindable] public var DataGridName:Object;
[Bindable] public var DataGridNameAC:Menu_Principal_Combobox;
private function centerWindow():void {
PopUpManager.centerPopUp(this);
}
private function closeWindow():void{
PopUpManager.removePopUp(this);
}
protected function combo_creationCompleteHandler(event:FlexEvent):void
{
getAllSexoResult.token = sexoService.getAllSexo();
}
private function saveName():void{
// closeWindow();
// update the name
DataGridName.codigo = codigoTextInput.text;
DataGridName.nombre = nombreTextInput.text;
DataGridName.apellido = apellidoTextInput.text;
// DataGridName.sexo = getAllSexoResult.lastResult(comboBox.selectedItem.sexo());
closeWindow();
}
protected function comboBox_creationCompleteHandler(event:FlexEvent):void
{
getAllSexoResult2.token = sexoService.getAllSexo();
}
private function changeCboMateria(e:Event):void {
}
]]>
</fx:Script>
<fx:Declarations>
<valueObjects:Pruebas_flash1 id="pruebas_flash1"/>
<s:CallResponder id="getAllSexoResult"/>
<sexoservice:SexoService id="sexoService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="getAllSexoResult2"/>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:TitleWindow x="33" y="9" width="292" height="259" title="Modificar Datos">
<mx:Form defaultButton="{button}" x="42" y="17" height="173">
<mx:FormItem label="Codigo">
<s:TextInput id="codigoTextInput" text="{DataGridName.codigo}"/>
</mx:FormItem>
<mx:FormItem label="Nombre">
<s:TextInput id="nombreTextInput" text="{DataGridName.nombre}"/>
</mx:FormItem>
<mx:FormItem label="Apellido">
<s:TextInput id="apellidoTextInput" text="{DataGridName.apellido}"/>
</mx:FormItem>
<s:Button id="button" label="cargar" />
<mx:FormItem label="Label">
<s:ComboBox id="comboBox1" creationComplete="comboBox_creationCompleteHandler(event)" labelField="cod_sexo" enabled="true">
<s:AsyncListView list="{getAllSexoResult2.lastResult}"/>
</s:ComboBox>
</mx:FormItem>
</mx:Form>
</s:TitleWindow>
</s:Group>