The problem in your code friend is because you´re trying to add itens to an
datagrid without existing first.

you can only add that if you have already created the container for it. so
addChild or initiate the popup before you do that.


and will works.

regards
Igor Costa
www.igorcosta.org
www.igorcosta.com

On Dec 12, 2007 1:49 AM, wpbarto <[EMAIL PROTECTED]> wrote:

>   Additional Info: This problem is apparantly caused by MULTIPLE
> itemEditEnd events dispatched from the DataGrid, exacerbated by the
> fact that the PopupManager code is not "reentrant" or doesn't
> handle "concurrency". Looks like Flash player can interrupt part of
> a running script (PopupManager's addPopup thread) and begin
> additional events.
>
> So:
> 1. Why is dataGrid sending 4-5 (!) itemEditEnd events for one edit
> action?
> 2. Shouldn't PopupManager be reliable and opaque without developers
> having to code around it's quirks?
>
> (Don't get me wrong--I love Flex; just don't like banging my head
> over framework issues. I have enough banging for my own issues!)
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>,
> "wpbarto" <[EMAIL PROTECTED]>
>
> wrote:
> >
> > I saw something else similar in flexcoders, but the information
> > didn't seem to apply to this case. I can create a popup window
> from
> > a button's click handler, but THE SAME CODE used when editing a
> > DataGrid cell FAILS!
> >
> > Is it a bug or a mis-use of PopupManager?? Thanks for any help!
> >
> > Top part of Error stack:
> > RangeError: Error #2006: The supplied index is out of bounds.
> > at flash.display::DisplayObjectContainer/addChildAt()
> > at
> >
> mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal:
> > :rawChildren_addChildAt()
> > at mx.managers::SystemManager/addChild()
> > at mx.managers::PopUpManagerImpl/addPopUp()
> > at mx.managers::PopUpManager$/addPopUp()
> > at TestPopup/::onCellEdit()
> > at TestPopup/__pointGrid_itemEditEnd()
> > at
> >
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv
> > entFunction()
> > at flash.events::EventDispatcher/dispatchEvent()
> > at mx.core::UIComponent/dispatchEvent()
> > at mx.controls::DataGrid/::endEdit()
> > at mx.controls::DataGrid/::deactivateHandler()
> > at
> >
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv
> > entFunction()
> > at flash.events::EventDispatcher/dispatchEvent()
> > at mx.core::UIComponent/dispatchEvent()
> > at mx.controls::DataGrid/::endEdit()
> >
> > This is the smallest example I can create:
> >
> > [File1: TestPopup.mxml]
> > ==================================================================
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > layout="absolute" applicationComplete="onAppComplete()">
> > <mx:Script>
> > <![CDATA[
> > import mx.managers.PopUpManager;
> > import mx.collections.ArrayCollection;
> > import mx.events.DataGridEvent;
> > import mx.events.DataGridEventReason;
> >
> > private var popWin:MyPopupWindow = null;
> >
> > private var curData:ArrayCollection; // items for datagrid
> >
> > private var items:ArrayCollection; // items for pop up
> >
> > private function onAppComplete():void {
> > curData = new ArrayCollection();
> > curData.addItem( { ident:"ORD", cityname:"Chicago, IL" } );
> > curData.addItem( { ident:"ATL", cityname:"Atlanta, GA" } );
> > curData.addItem( { ident:"DEN", cityname:"Denver, CO" } );
> > curData.addItem( { ident:"", cityname:"" } ); // one blank
> >
> > pointGrid.rowCount = 5;
> > pointGrid.dataProvider = curData;
> >
> > items = new ArrayCollection();
> > items.addItem( {ident:"JFK", cityname:"New York, NY"} );
> > items.addItem( {ident:"LAX", cityname:"Los Angeles, CA"} );
> > items.addItem( {ident:"SEA", cityname:"Seattle, WA"} );
> > }
> >
> > private function onClick():void {
> > if(popWin == null) {
> > popWin = new MyPopupWindow();
> > popWin.itemChoices = items;
> > }
> > PopUpManager.addPopUp(popWin, this, true);
> > PopUpManager.centerPopUp(popWin);
> > }
> >
> > private function onCellEdit(event:DataGridEvent):void {
> > if(event.reason == DataGridEventReason.CANCELLED)
> > return;
> > if(popWin == null) {
> > popWin = new MyPopupWindow();
> > popWin.itemChoices = items;
> > }
> > PopUpManager.addPopUp(popWin, this, true);
> > PopUpManager.centerPopUp(popWin);
> > }
> > ]]>
> > </mx:Script>
> >
> > <mx:VBox>
> > <mx:Label text="Clicking the button creates popup OK:" />
> > <mx:Button id="theButton" label="Click Me" click="onClick()"/>
> > <mx:Label text="However, editing a cell FIRST fails:" />
> > <mx:DataGrid id="pointGrid" itemEditEnd="onCellEdit(event)"
> > editable="true">
> > <mx:columns>
> > <mx:DataGridColumn id="identCol" width="50" dataField="ident"
> > headerText="Ident"/>
> > <mx:DataGridColumn id="citynameCol" width="90"
> > dataField="cityname" headerText="City/Name" paddingLeft="1"
> > paddingRight="1"/>
> > </mx:columns>
> > </mx:DataGrid>
> > </mx:VBox>
> > </mx:Application>
> >
> > [File2: MyPopupWindow.mxml]
> > ==================================================================
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute"
> > width="400" height="300" title="The Popup Window">
> >
> > <mx:DataGrid id="selItemList" dataProvider="{itemChoices}"
> > width="100%" height="100%">
> > <mx:columns>
> > <mx:DataGridColumn id="identCol" dataField="ident"
> > headerText="Ident"/>
> > <mx:DataGridColumn id="typeCol" dataField="cityname"
> > headerText="City"/>
> > </mx:columns>
> > </mx:DataGrid>
> > <mx:ControlBar width="100%">
> > <mx:Spacer width="100%"/>
> > <mx:Button label="Cancel" click="onCancel()"/>
> > </mx:ControlBar>
> >
> > <mx:Script>
> > <![CDATA[
> > import mx.managers.PopUpManager;
> > import mx.collections.ArrayCollection;
> >
> > [Bindable] public var itemChoices:ArrayCollection =
> > new ArrayCollection();
> >
> > private function onCancel():void {
> > PopUpManager.removePopUp(this);
> > }
> > ]]>
> > </mx:Script>
> > </mx:Panel>
> >
>
>  
>



-- 
----------------------------
Igor Costa
www.igorcosta.com
www.igorcosta.org

Reply via email to