Sorry for dragging up an old thread, but I'm struggling with the same
issue and haven't found a solution.
I have created an item editor component for my datagrid. The
component creates and passes the datagrid row data over to the popup.
Code snippets below.
However, clicking anything on the popup results in focus being removed
from the datagrid cell. This fires the itemEditEnd event for the
datagrid. After closing the popup, focus is returned to the datagrid
cell, resulting in the column itemEditor regaining focus, and the
popup returning -- a loop.
I've tried changing focusEnabled to false for all elements in the
popup (including the popup container), as suggested elsewhere in the
list. However, this has no effect.
Any ideas? I read that that other on this list have solved this issue.
Thanks!
Mike
<mx:DataGrid editable="true" itemEditBegin="trace('begin')"
itemEditEnd="trace('end');" itemEditBeginning="trace('begining')">
<mx:dataProvider>
<mx:ArrayCollection>
<mx:source>
<mx:Object macro_id="D2456" teeth="11" />
</mx:source>
</mx:ArrayCollection>
</mx:dataProvider>
<mx:columns>
<mx:DataGridColumn dataField="macro_id" headerText="Code"
width="75" editable="true" />
<mx:DataGridColumn dataField="teeth" headerText="Teeth"
width="50" editable="true" itemEditor="modules.Case.TeethEditor"
editorDataField="teeth" />
</mx:columns>
</mx:DataGrid>
<?xml version="1.0" encoding="utf-8"?>
<!-- modules.Case.TeethEditor -->
<mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="_init()" text="{teeth}" editable="false">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import modules.Case.TeethSelector;
[Bindable]
public var teeth:String;
private var _popup:TeethSelector;
private function _init():void
{
teeth = data.teeth;
popTeethSelector();
}
private function popTeethSelector():void
{
_popup = new TeethSelector();
_popup.teeth = teeth;
_popup.addEventListener("updated", _updateTeeth);
_popup.focusEnabled = false;
PopUpManager.addPopUp(_popup, this);
PopUpManager.centerPopUp(_popup);
}
private function _updateTeeth(e:Event):void
{
teeth = _popup.teeth;
}
]]>
</mx:Script>
</mx:TextInput>
<?xml version="1.0" encoding="utf-8"?>
<!-- TeethSelector -->
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="230"
height="430" title="Tooth Selector" layout="absolute"
creationComplete="_init()" showCloseButton="true"
close="PopUpManager.removePopUp(this)" focusEnabled="false">
<mx:Metadata>
[Event("updated")]
</mx:Metadata>
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
import mx.utils.StringUtil;
public var teeth:String;
private function _init():void
{
// ...
}
private function _done():void
{
// ...
PopUpManager.removePopUp(this);
this.dispatchEvent( new Event("updated") );
}
]]>
</mx:Script>
<mx:Canvas id="selector" width="200" height="325" x="4" y="4"
focusEnabled="false">
<!-- ... --->
<mx:CheckBox x="33" y="137" id="_28" focusEnabled="false"/>
<mx:Button x="144" y="303" label="Done" click="_done()"
focusEnabled="false"/>
</mx:Canvas>
</mx:TitleWindow>
--- In [email protected], "fritzdimmel" <[EMAIL PROTECTED]> wrote:
>
> Hi!
> I was thinking similar to you, but I didn't get it out, how to
> implement this.
> How can I react on the itemEditBeginning event within the component.
> E.g. I've a Canvas as itemEditor. I could open the window on
> initialize. But: how can I then put some values to the popup? Within
> the canvas I just have the "data" object, which only gives me the
> values of the current row in the datagrid. for the popup this may be
> enough (more or less) but when the popup is closed, how can I dispatch
> the itemEditEnd or something like that for the grid, without having
> further information?
>
> Can anyone please show me some lines of code, how to implement this?
>
> Thanks,
> Fritz
>
> --- In [email protected], "Michael Labriola" <labriola@>
> wrote:
> >
> >
> > My first thought:
> >
> > I would probably write a simple component that serves as an
> > itemRenderer. From within that component I would be to launch a
> > modal popup window from the itemEditBeginning event. Ensure that you
> > pass the row and the dataGridColumn (much like a labelFunction) to
> > the new popup. Have it do whatever it is that needs to be done.
> >
> > Then listen for the popup to close and manually handle the update to
> > the collection through the renderer by listening to itemEditEnd.
> >
> > This is just a high level thought. There are some other details, but
> > the concept would probably work with a bit of tweaking.
> >
> > --mike
> >
> > --- In [email protected], "fritzdimmel" <fritz.dimmel@>
> > wrote:
> > >
> > > Hi!
> > > I'm searching for a solution, to use e.g. a popup-window as
> > itemEditor
> > > in a flex datagrid. Using a Textinput, NumericStepper,
> > Checkbox, ...
> > > is quite easy, but I want to have a little "bigger" (in size)
> > > component. Now I have the problem that, when I use a custom Panel
> > > component as itemEditor, that it will be trapped within the
> > datagrid's
> > > dimensions.
> > >
> > > Is there another way (which I haven't found by now) to use a popup
> > as
> > > datagrid item editor?
> > >
> > > Thanks!
> > > Fritz
> > >
> >
>