You will need to create an event listener on the System Manager to trigger on 
the window close event (Will probably have to be at the application level). 
once the event triggers, grab the data that you need and inject it into the 
component that needs it. NB. System Manager handles all window events.

--- In flexcoders@yahoogroups.com, "ilikeflex" <ilikef...@...> wrote:
>
> Hi
> 
> I am trying to create editable datagrid. I have also implemented itemEditEnd 
> event because i have nested datafield. I have custom itemeditor. In the 
> custom itemeditor, i have textInput and button to open the popup. I click to 
> open open pop up.I write some text in the pop up but that that text does not 
> appear in itemeditor after close popup.
> 
> I have attached sample test code.I have added snippets but if you required i 
> can add complete test case.
> 
> PopUp
> <?xml version="1.0" encoding="utf-8"?>
> <mx:TitleWindow xmlns="customComponents.popups.*"
>                               xmlns:mx="http://www.adobe.com/2006/mxml";
>                               xmlns:prgbar="com.vzw.framework.prgbar.*"
>                               width="100%"
>                               height="100%"
>                               verticalScrollPolicy="off"
>                               styleName="popupStyle">
>       <mx:Script>
>               <![CDATA[
>                       import mx.managers.PopUpManager;
>                       public var opener:Object;
>                       public var testTextInputText:String;
>                       public function onTextChange(event:Event):void
>                       {
>                               testTextInputText=(event.currentTarget as 
> TextInput).text;
>                       }
>                       
>                       public function onOkClick():void
>                       {
>                               if(opener) opener.onPopUpClose();
>                               PopUpManager.removePopUp(this);
>                       }
>               ]]>
>       </mx:Script>
>       <mx:VBox width="100%"
>                        height="100%"
>                        paddingBottom="0">
>               <mx:TextInput text=""
>                                         id="testTextInput"
>                                         change="onTextChange(event)"/>
>               <mx:Button label="ok" click="onOkClick()"/>                     
>   
>       </mx:VBox>
> </mx:TitleWindow>
> 
> 
> ItemEditor
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
>                width="100%"
>                height="200"
>                horizontalAlign="center"
>                implements="customComponents.datagrid.IEditorValue">
>       
>       <mx:TextInput id="txtInputByUser"/>
>       <mx:Image source="assets/images/spyglass.gif"
>                         buttonMode="true"
>                         click="onUserClick(event)"/>
>       <mx:Script>
>               <![CDATA[
>                       import mx.events.CollectionEvent;
>                       import mx.collections.ArrayCollection;
>                       import mx.managers.PopUpManager;
>                       import customComponents.popups.CustomPopup;
>                       import mx.controls.listClasses.BaseListData;
> 
>                       // Internal variable for the property value.
>                       private var _listData:BaseListData;
> 
>                       // Make the listData property bindable.
>                       [Bindable("dataChange")]
> 
>                       // Define the getter method.
>                       public function get listData():BaseListData
>                       {
>                               return _listData;
>                       }
> 
>                       // Define the setter method,
>                       public function set listData(value:BaseListData):void
>                       {
>                               _listData=value;
>                       }
> 
>                       public function get editValue():String
>                       {
>                               var returnString:String="";
>                               returnString=txtInputByUser.text;
>                               return returnString;
>                       }
> 
>                       public var win:CustomPopup;
>                       
>                       
>                       public function onPopUpClose():void
>                       {
>                               txtInputByUser.text = win.testTextInputText;
>                               trace("Input At popup " +  
> win.testTextInputText);
>                       }
>                       
>                       protected function onUserClick(evt:Event):void
>                       {
>                               if(win==null)
>                               win=new CustomPopup();
>                               win.width=300;
>                               win.height=330;
>                               var point:Point=new Point(0, 0);
>                               point=evt.target.localToGlobal(point);
>                               win.y=point.x;
>                               win.x=point.y;
>                               PopUpManager.addPopUp(win, this, true);
>                               PopUpManager.centerPopUp(win);
>                       }
>               ]]>
>       </mx:Script>
> </mx:HBox>
> 
> 
> 
> Method
> 
> private function onitemEditEnd(event:DataGridEvent):void
> {
>       var datGrid:DataGrid=(event.currentTarget as  DataGrid);
>       if (event.reason == DataGridEventReason.CANCELLED)
>               return;
> 
>       var selectedObject:Object=datGrid.dataProvider[event.rowIndex];
>       var field:String=datGrid.columns[event.columnIndex].dataField;
>       var array:Array=field.split(".");
>       if (array!= null && array.length >= 2)
>       {
>               event.preventDefault();
>               
>               var object:Object=selectedObject[array[0]];
>               var textEnteredByUser:String;
>               if(datGrid.itemEditorInstance is IEditorValue)
>               {
>                       
> textEnteredByUser=IEditorValue(datGrid.itemEditorInstance).editValue;
>                       object[array[1]]=textEnteredByUser;
>               }
>               else
>               {
>                       textEnteredByUser = 
> TextInput(datGrid.itemEditorInstance).text;
>                       object[array[1]]= textEnteredByUser;
>               }
>                       
>               //datGrid.destroyItemEditor();
>               datGrid.dataProvider.itemUpdated(event.itemRenderer.data);
>       }
> }
> 
> 
> package customComponents.datagrid
> {
>       import mx.controls.listClasses.IDropInListItemRenderer;
>       import mx.controls.listClasses.BaseListData;
> 
>       public interface IEditorValue extends IDropInListItemRenderer
>       {
>               function get editValue():String;        
>       }
> }
> 
> Thanks
> ilikeflex
>


Reply via email to