This quick and dirty example (Based on the Adobe Documentation) should
get you well on your way:

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";>
     <mx:Script>
         <![CDATA[
               import mx.collections.ArrayCollection;

               [Bindable] private var dpHierarchy:ArrayCollection = new
ArrayCollection([
               {Region:"Southwest", children: [
                  {Region:"Arizona", children: [
                     {Territory_Rep:"Barbara Jennings", Actual:38865,
Estimate:40000, URL:"www.apple.com"},
                     {Territory_Rep:"Dana Binn", Actual:29885,
Estimate:30000, URL:"www.adobe.com"}]},
                  {Region:"Central California", children: [
                     {Territory_Rep:"Joe Smith", Actual:29134,
Estimate:30000, URL:"www.google.com"}]},
                  {Region:"Nevada", children: [
                     {Territory_Rep:"Bethany Pittman", Actual:52888,
Estimate:45000, URL:"www.amazon.com"}]},
                  {Region:"Northern California", children: [
                     {Territory_Rep:"Lauren Ipsum", Actual:38805,
Estimate:40000, URL:"www.microsoft.com"},
                     {Territory_Rep:"T.R. Smith", Actual:55498,
Estimate:40000, URL:"www.yahoo.com"}]},
                  {Region:"Southern California", children: [
                     {Territory_Rep:"Alice Treu", Actual:44985,
Estimate:45000, URL:"www.ibm.com"},
                     {Territory_Rep:"Jane Grove", Actual:44913,
Estimate:45000, URL:"www.bing.com"}]}
               ]}
             ]);
         ]]>
     </mx:Script>
     <mx:AdvancedDataGrid width="100%" height="100%">
         <mx:dataProvider>
             <mx:HierarchicalData source="{dpHierarchy}"/>
         </mx:dataProvider>
         <mx:columns>
             <mx:AdvancedDataGridColumn dataField="Region"/>
             <mx:AdvancedDataGridColumn dataField="Territory_Rep"
headerText="Territory Rep"/>
             <mx:AdvancedDataGridColumn dataField="Actual"/>
             <mx:AdvancedDataGridColumn dataField="Estimate"/>
             <mx:AdvancedDataGridColumn id="actionCol"
headerText="Action"/>
         </mx:columns>
         <mx:rendererProviders>
             <mx:AdvancedDataGridRendererProvider column="{actionCol}"
                 depth="3" renderer="PopUpMenuButtonRenderer"/>
         </mx:rendererProviders>
     </mx:AdvancedDataGrid>
</mx:Application>

PopUpMenuButtonRenderer.as:
package
{
     import mx.controls.*;
     import mx.events.MenuEvent;
     import flash.net.URLRequest;
     import flash.net.navigateToURL;

     public class PopUpMenuButtonRenderer extends PopUpMenuButton
     {
         private var _URL:String;
         private static const menuItems:Array = ["Go to Web Site", "Do
Something Else"];

         public function PopUpMenuButtonRenderer()
         {
             super();
         }

         override public function set data(value:Object):void
         {
             if(value != null)
             {
                 super.data = value;
                 _URL = value["URL"];
                 addEventListener(MenuEvent.ITEM_CLICK, onMenuClick)
                 label = "Action";
                 dataProvider = menuItems;
             }
         }

         private function onMenuClick(event:MenuEvent):void
         {
             switch(event.label)
             {
                 case "Go to Web Site":
                     navigateToURL(new URLRequest("http://"; +
_URL),"_top");
                 break;
             }
         }
     }
}


HTH





Steve

--- In flexcoders@yahoogroups.com, "thomas_13s" <thomas_...@...> wrote:
>
> Hi,
> I have an advanced data grid , with 8 columns one of the columns i
want the 8 th column as a POPUPMenu Button,  and when I click on the
menu item it should navigate to a url value which is in the Array dArr.
Array dArr has 2 values ,how can i do this I have tried many things.
>  Array dArr has the values [dd.label,dd.url] and some valuses in the
array has more than one occurence, I mean
[dd.label1,dd.url1],[dd.label2,dd.url2].
> The values to be populated in the POPUPMenuButton , i have in an array
dArr.
> please help me out.
> <?xml version="1.0"?>
> <!-- Dashboard Main Service Summary table -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; width="100%"
height="100%" backgroundColor="#FFFFFF"
>                 initialize="initApp();"
creationComplete="onCreationComplete();">
>   <mx:Style>
>     .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
align:center; }
>   </mx:Style>
>   <mx:Script>
>     <![CDATA[
>
>   var ddArr:ArrayCollection = new ArrayCollection();
> var dp:ArrayCollection = new ArrayCollection();
>
>  var ddLabel:String="";
>           var ddUrl:String="";
>           var ddData:String="";
>           var ddRest:String="";
>           var popUpB:PopUpMenuButton;
>
>
>
> ddData=  xd[9];
>               ddRest=ddData;
>               var ddidx:int = ddData.indexOf("|");
>              // var  dObj:Object=new Object();
>                while ( ddidx > 0 )
>                {
>
>                    ddLabel= ddRest.substring( 0, ddidx );
>
>                    ddRest= ddRest.substring(ddidx + 1  );
>                     ddidx = ddRest.indexOf("|");
>                if(       ddidx > 0)
>                {
>               // ddUrl= ddRest.substring(ddidx + 1  );
>                 ddUrl= ddRest.substring(0, ddidx   );
>
>                  ddRest= ddRest.substring(ddidx + 1  );
>                      ddidx = ddRest.indexOf("|");
>                }
>
>                   dObj.label=  ddLabel;
>                   dObj.url=    ddUrl;
>                  ddArr.addItem(dObj);
>
>                }
>                popUpB=new PopUpMenuButton();
>                myMenu = new Menu();
>                myMenu.labelField = "Action";
>                 myMenu.showRoot = true;
>                 myMenu.width = popUpB.width;
>                 myMenu.selectedIndex = 0;
>                 myMenu.dataProvider =  ddArr;
>
>                // myMenu.addEventListener("itemClick",
itemClickHandler);
>
>                popUpB.popUp = myMenu;
>
> dp.addItem( { "Index":xd[0], "Service":xd[1], "Priority":xd[2],
"Current SLA":xd[3],"Health":xd[4], "Quality":xd[5],
>                           "Risk":xd[6], "Avail":xd[7], "OpMode":xd[8],
"dd":popUpB} );
>  dp = dpSrv;
>   gc.source=dp;
>        gc.refresh();
>
>  ]]>
>
>  </mx:Script>
>
> <mx:HTTPService id="sst" resultFormat="text"
result="onJSONLoad(event)" url="{sURL}" fault="onFaultLoad(event)"/>
>   <mx:Panel title="{cTitle}" width="100%" height="100%"
titleStyleName="hStyle" headerColors="[0xC5DFF9,0xEFF6FF]" >
>
> <mx:AdvancedDataGrid id="srvTable" width="100%" height="100%"
color="0x323232" dragEnabled="true" dropEnabled="true"
>  enabled="true" showHeaders="true"
> displayItemsExpanded="true" variableRowHeight="true" wordWrap="false"
initialize="gc.refresh();"  >
> <mx:dataProvider>
>               <mx:GroupingCollection id="gc" source ="{dpSrv}">
>                     <mx:grouping>
>                         <mx:Grouping>
>                           <!-- <mx:GroupingField name="PService" />
-->
>                             <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollection>
>                <!-- <mx:HierarchicalData id="gc" source="{dpSrv}"/>  
-->
>                 </mx:dataProvider>
>
>             <mx:columns>
>
> <mx:AdvancedDataGridColumn id ="ddcol" dataField="dd"  headerText="
Drill-down" width="200" textAlign="left">
>
>                  </mx:AdvancedDataGridColumn>
>
>                </mx:columns>
>
>        <mx:rendererProviders>
>              <mx:AdvancedDataGridRendererProvider dataField="dd"
depth="1" column="{ddcol}"  columnIndex="8"
>              renderer="mx.controls.PopUpMenuButton" />
>           </mx:rendererProviders>
>  </mx:AdvancedDataGrid>
>  </mx:Panel>
> </mx:Application>
>
> thanks in advance,
> Tom.
>

Reply via email to