2 Replies Latest reply on Dec 5, 2010 11:27 PM by DrBarash

    ADG + menu problem

    DrBarash

      Hello,

       

      I am trying to add a left-click menu to an advanced data grid in flex 3.5.

       

      The process should go like this:

       

      1. user click on an ADG parent filed.

      2. a Menu opens

      3. user select some option of the menu

      4. the ADG does it thing (slides other parts of tree down and display the child node).

       

      BUT, the ADG does phaze 4 right after the user clicks... and thats bad for me.

       

       

      Can anyone help me?

       

      Thank you

       

      Ido

        • 1. Re: ADG + menu problem
          DrBarash Level 1

          Here is an MXML that simulates my porblem (taken from tour de flex and edited):

           

           

           

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

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"

          horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">

           

          <mx:Script>

          <![CDATA[

          import mx.collections.ArrayCollection;

          import mx.controls.Menu;

          import mx.events.AdvancedDataGridEvent;

          import mx.events.MenuEvent;

           

          /** Item that is currently beeing expanded /collapsed */

          public var currentItem:Object;

           

          /** Attribution selection popup menu */

          private var attributionMenu:Menu;

           

          /** Flag to indicate if the attribution popup menu is closed without selecting an item */

          private var hideWithoutClick:Boolean;

           

           

          [Bindable]

          private var dpFlat:ArrayCollection = new ArrayCollection([

          {Region:"Southwest", Territory:"Arizona",

          Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},

          {Region:"Southwest", Territory:"Arizona",

          Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}, 

          {Region:"Southwest", Territory:"Central California",

          Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}, 

          {Region:"Southwest", Territory:"Nevada",

          Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}, 

          {Region:"Southwest", Territory:"Northern California",

          Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},

          {Region:"Southwest", Territory:"Northern California",

          Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}, 

          {Region:"Southwest", Territory:"Southern California",

          Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},

          {Region:"Southwest", Territory:"Southern California",

          Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000},

          {Region:"NorthEast", Territory:"New York",

          Territory_Rep:"Jose Rodriguez", Actual:26992, Estimate:30000},

          {Region:"NorthEast", Territory:"New York",

          Territory_Rep:"lisa Sims", Actual:47885, Estimate:50000}, 

          {Region:"NorthEast", Territory:"Massachusetts",

          Territory_Rep:"kelly o'connell", Actual:172911, Estimate:20000},

          {Region:"NorthEast", Territory:"Pennsylvania",

          Territory_Rep:"John Barnes", Actual:32105, Estimate:30000},

          {Region:"MidWest", Territory:"Illinois",

          Territory_Rep:"Seth Brown", Actual:42511, Estimate:40000}

          ]);

           

          private var dpMenu:ArrayCollection = new ArrayCollection([1,2,3,4]);

           

           

          public function itemExpanded(event:AdvancedDataGridEvent):void

          {

           

           

          if (!event.opening) return;

           

          currentItem = event.item;

          this.ADG.expandItem(currentItem, false);

           

           

          attributionMenu = Menu.createMenu(ADG,dpMenu,false);

          // attributionMenu.addEventListener((MenuEvent.ITEM_CLICK,attributionMenuClickHandler);

          // attributionMenu.addEventListener(MenuEvent.MENU_HIDE,attributionMenuHideHandler);

           

          hideWithoutClick = true;

           

          var contentToLocal:Point = ADG.contentToLocal(new Point(ADG.contentMouseX,ADG.contentMouseY));

          var point:Point = ADG.localToGlobal(new Point(contentToLocal.x,contentToLocal.y));

           

          attributionMenu.show(point.x-2,point.y-2);

          }

           

          ]]>

          </mx:Script>

          <mx:Panel title="AdvancedDataGrid Control" layout="vertical" color="0xffffff" borderAlpha="0.15" width="500"

            paddingTop="5" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center">

           

          <mx:AdvancedDataGrid id="ADG" width="100%" height="100%" color="0x323232" initialize="gc.refresh();"

          itemOpening="itemExpanded(event)">       

          <mx:dataProvider>

          <mx:GroupingCollection id="gc" source="{dpFlat}">

          <mx:grouping>

          <mx:Grouping>

          <mx:GroupingField name="Region"/>

          <mx:GroupingField name="Territory"/>

          </mx:Grouping>

          </mx:grouping>

          </mx:GroupingCollection>

          </mx:dataProvider>       

           

          <mx:columns>

          <mx:AdvancedDataGridColumn dataField="Region"/>

          <mx:AdvancedDataGridColumn dataField="Territory"/>

          <mx:AdvancedDataGridColumn dataField="Territory_Rep"

             headerText="Territory Rep"/>

          <mx:AdvancedDataGridColumn dataField="Actual"/>

          <mx:AdvancedDataGridColumn dataField="Estimate"/>

          </mx:columns>

          </mx:AdvancedDataGrid>

           

          </mx:Panel>

          </mx:Application>

          • 2. Re: ADG + menu problem
            DrBarash Level 1

            Help,  someone...

             

            I found something that works on trees, but not in ADG.

             

            ADG.expandItem(event.item, false, false, false, event);