0 Replies Latest reply on Jan 29, 2010 10:59 PM by Deepa Ganesan

    Add Custom Right click menu on editable AdvancedDataGrid

    Deepa Ganesan

      Hi,

       

      I have an AdvancedDataGrid whose editable property is set to true and selectionmode is multipleCells.

      Is it possible to display custom right click menu when i right click on any cell? Am getting only the

      default menu items (Cut, Copy, Paste, Select All). Am using ContextMenu and ContextMenuItem class

      for creating the custom right click menu. The same code is working in Flex and not in AIR. Do we have

      to use NativeMenu in Adobe AIR? Please help. Attaching sample of my code.

       

      <mx:Script>

       

      <![CDATA[

       

       

      [Bindable]

       

      private var cMenu:ContextMenu;

       

       

      public function createContextMenu():void {

          

           cMenu =

      new ContextMenu();

           cMenu.hideBuiltInItems();

           cMenu.addEventListener(ContextMenuEvent.MENU_SELECT, contextMenu_menuSelect);

       

       

           var cMenuItemCopy:ContextMenuItem = new ContextMenuItem("Copy Data");

           cMenuItemCopy.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItemSelect_Copy);

       

           var cMenuItemPaste:ContextMenuItem = new ContextMenuItem("Paste Data");

           cMenuItemPaste.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuItemSelect_Paste);

       

           cMenu.customItems.push(cMenuItemCopy);

           cMenu.customItems.push(cMenuItemPaste);

          

      this.contextMenu = cMenu;    

       

       

      }

       

      private

       

       

      function contextMenu_menuSelect(event:ContextMenuEvent):void {

       

      }

       

       

      private function contextMenuItemSelect_Copy(event:ContextMenuEvent):void {

           copy(event);

      }

       

       

      private function contextMenuItemSelect_Paste(event:ContextMenuEvent):void {

           paste(event);

      }

      ]]>

      </mx:Script>

      <mx:AdvancedDataGrid

       

      width="100%" height="72%" id="dProvider" creationComplete="init()"

            editable="true" itemEditBeginning="checkIfAllowed(event)" itemEditEnd="onEditEnd(event)"

            selectionMode="multipleCells" itemRenderer="renderer.ColorForDashBoard" contextMenu="{cMenu}"/ >