3 Replies Latest reply on Mar 4, 2011 9:42 AM by jfb00

    mx:AdvancedDataGrid bug?

    andres margalef

      When i click on button works well, but when i click on the image not.

      This is the application. To make a test, add the /assets/image.png

       

      <?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"

      >

       

      <fx:Declarations>

      <s:ArrayCollection id="dataList">

      <fx:Object movNumeroMov="1" name1="name1" name2="name2" name3="name3" name4="name4" name5="name5" />

      <fx:Object movNumeroMov="1" name1="name1" name2="name2" name3="name3" name4="name4" name5="name5" />

      <fx:Object movNumeroMov="1" name1="name1" name2="name2" name3="name3" name4="name4" name5="name5" />

      </s:ArrayCollection>

      </fx:Declarations>

       

       

      <mx:AdvancedDataGrid width="100%" height="100%" dataProvider="{dataList}" editable="true">

      <mx:columns>

      <mx:AdvancedDataGridColumn editable="false" dataField="name1" />

      <mx:AdvancedDataGridColumn editable="false" dataField="name1" >

      <mx:itemRenderer>

      <fx:Component>

      <mx:VBox>

      <fx:Script>

      <![CDATA[

      import mx.controls.Alert;

      import mx.events.CloseEvent;

       

      [Bindable][Embed(source="assets/image.png")]

      public static var deleteIcon:Class;

       

       

      public function closeHandler(closeEvent:CloseEvent):void {

      if(closeEvent.detail == Alert.YES) {

      var index:uint = outerDocument.dataList.getItemIndex(data);

      outerDocument.dataList.removeItemAt(index);

      }

      }

       

      protected function button1_clickHandler(event:MouseEvent):void {

      Alert.show("message", "title", Alert.YES|Alert.NO, null, closeHandler);

      }

      ]]>

      </fx:Script>

      <s:Button click="button1_clickHandler(event)" />

      <mx:Image click="button1_clickHandler(event)" source="{deleteIcon}" />

      </mx:VBox>

      </fx:Component>

      </mx:itemRenderer>

      </mx:AdvancedDataGridColumn>

      </mx:columns>

      </mx:AdvancedDataGrid>

      </s:Application>

        • 1. Re: mx:AdvancedDataGrid bug?
          jfb00 Level 3

          Hi,

          Replace your mx:image for a mx:button and place your image there like:

          <mx:Button click="button1_clickHandler(event)" icon="@Embed('assets/image.png')"/>

           

          Rgds

          Johnny

          • 2. Re: mx:AdvancedDataGrid bug?
            andres margalef Level 1

            Using buttons works fine, but why with the image the data grid fail?, i think it is a bug in the AdvancedDataGrid

            • 3. Re: mx:AdvancedDataGrid bug?
              jfb00 Level 3

              Hi,

              Something with the close handler is not working.

              If you try to delete directly from the click, works.

               

               protected function button1_clickHandler(event:Event):void {
                                                      //Alert.show("message", "title", Alert.YES|Alert.NO, null, closeHandler);
                                                      var index:uint = outerDocument.dataList.getItemIndex(data);
                                                      outerDocument.dataList.removeItemAt(index);
                                                  }
              
               <mx:Image source="{deleteIcon}" useHandCursor="true" buttonMode="true" click="button1_clickHandler(event)" />
              

               

              Johnny