Datagrid and a close button

497
1
07-05-2011 07:11 AM
jerrysalinas
New Contributor
Hi,
I have a datagrid that pops up with a click on the map, but I would like to add a close button(X), so the user can close the grid and clear the graphic. I can't figure out how to enable the close event. I keep getting "call to a possibly undefined method CloseMe"
Also, sometimes the datagrid is too long in width and goes beyond the screen, is there a way to limit the size and always center the datagrid. I am using Flex4 and it is non-sfv. thnx. Jerry

<esri:InfoSymbol id="drcogInfoSymbol" containerStyleName="drcogInfoSymbolStyle">
   <esri:infoRenderer>
    <fx:Component className="MyInfoWindowRenderer">

     <mx:VBox>
      <mx:HBox width="100%">
       <mx:Label text="{data[0].LOCATION}" fontWeight="bold" />
       <mx:Spacer width="100%"/>
     
       <s:Button id="closeButton"
           width="20" height="20" toolTip="close" click="CloseMe(event)"/> 
<!--        <mx:Button id="closeButton" label="close" click="outerDocument.myButton_clickHandler(event)"   width="18" height="18"/> -->
       </mx:HBox>
     
      <mx:DataGrid   height="100%" width="100%" dataProvider="{data}" 
            horizontalScrollPolicy="auto" verticalScrollPolicy="on">

      </mx:DataGrid>
     </mx:VBox>
    </fx:Component>
   </esri:infoRenderer>
  </esri:InfoSymbol>

public function closeMe(event:Event):void
   {
    PopUpManager.removePopUp(this);
Alert.show("My closed button was clicked!");
   }
Tags (2)
0 Kudos
1 Reply
jerrysalinas
New Contributor
got it to work by adding to two lines below. probably not the right way, but it is working...

Just can't figure out why my datagrid is being buried under my layers. The datagrid is being overlapped by the map features, versus on top. Is there a fix for this.
clickGraphic.addEventListener("closeMe", closeMeHandler);

and

dispatchEvent(new Event("closeMe", true));

and


private function closeMeHandler(event:Event):void
   {
    var graphic:Graphic = event.currentTarget as Graphic;
    graphic.visible = false;
    //Alert.show("My button was clicked!");
   }


and

<mx:Button skin="@Embed(source='assets/images/close.png')" right="30">
       
        <mx:click>
         <![CDATA[
         dispatchEvent(new Event("closeMe", true));
         ]]>
        </mx:click>
       </mx:Button>
0 Kudos