6 Replies Latest reply on May 25, 2011 4:34 AM by Andrea Varga

    Problem using DropDownList as itemEditor in AdvancedDataGrid

    Andrea Varga

      Hi All,

       

      I am using DropDownList in the itemEditor of an  AdvancedDataGrid. The problem: after an item is selected from the DropDownList and the mouse is released over the AdvancedDataGrid's row, that row gets selected and the cell edited (DropDownList appears), but it should not. It works correctly with the DataGrid.

      You can try it out in this example: http://narancs.net/flex/ADGTest/index.html
      Edit the 'year' column in the first row, and select 2003. You'll see that the 4th row will get edited in the AdvancedDataGrid but not in the DataGrid

      Source: http://narancs.net/flex/ADGTest/srcview/http://narancs.net/flex/ADGTest/srcview/

      Do you have an idea how to fix this issue in the AdvanncedDataGrid?

       

      Thanks,
      Andrea

        • 1. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
          agroni000

          I see the same problem too. Also, if you use the keyboard to select an item from DropDownList the row selector of the AdvancedDataGrid will jump to the position of where the selected DropDownList item was.

           

          To me it looks like a bug on the AdvancedDataGrid because the last event message to the ItemRenderer is being executed by the AdvancedDataGrid too.

          • 2. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
            rahuls9009

            able to reproduce it.. please log it as a bug..

            • 3. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
              agroni000 Level 1

              I would log this bug but I don't see anything like a bug reporting tool on this web site.

              Sorry.

              • 4. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
                Raju Khinda

                Create a custom :DropDownList and override default behaviour . It will solve your problem.

                 

                 

                <?xml version="1.0" encoding="utf-8"?>

                <s:DropDownList 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="400" height="300">

                <fx:Declarations>

                <!-- Place non-visual elements (e.g., services, value objects) here -->

                </fx:Declarations>

                <fx:Script>

                <![CDATA[

                import mx.events.DropdownEvent;

                 

                import spark.events.DropDownEvent;

                protected override function   dropDownController_closeHandler(event:DropDownEvent):void

                {

                systemManager.getSandboxRoot().addEventListener(MouseEvent.MOUSE_UP, systemManager_mouseUpHandler, true);

                super.dropDownController_closeHandler(event);

                }

                 

                 

                protected function systemManager_mouseUpHandler(event:MouseEvent):void

                {

                systemManager.getSandboxRoot().removeEventListener(MouseEvent.MOUSE_UP, systemManager_mouseUpHandler, true);

                event.stopImmediatePropagation();

                }

                ]]>

                </fx:Script>

                </s:DropDownList>

                1 person found this helpful
                • 5. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
                  Nishant Jha28 Level 2

                  I think overriding only the mouse down should do. But this seems to be a bug. We are trying to select an element in the list and not click on the row in the grid. This shouldnt be the default behaviour.

                  • 6. Re: Problem using DropDownList as itemEditor in AdvancedDataGrid
                    Andrea Varga Level 1

                    Yes, that's what I ended up doing (overriding mouse down) back then, when I posted the question, just forgot to post my solution/workaround.

                     

                    package ui.components {
                    import flash.events.MouseEvent;

                    import spark.components.DropDownList;

                     

                    public class DropDownListInItemEditor extends DropDownList {
                        public function DropDownListInItemEditor() {
                            super();
                        }

                     

                        override protected function item_mouseDownHandler(event:MouseEvent):void {

                            super.item_mouseDownHandler(event);
                            openDropDown();
                            dropDown.addEventListener(MouseEvent.MOUSE_UP, ddMouseUpHandler, false);

                        }

                     

                        private function ddMouseUpHandler(event:MouseEvent) : void {
                            if(isDropDownOpen) {
                                closeDropDown(false);
                            }
                            dropDown.removeEventListener(MouseEvent.MOUSE_UP, ddMouseUpHandler, false);
                        }

                     

                    }
                    }