How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

View: New views
15 Messages — Rating Filter:   Alert me  

How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.


Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by valdhor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@..., "thomas_13s" <thomas_13s@...> 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.
>


Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
thanks in advance,
Tom.


--- In flexcoders@..., "valdhor" <valdhorlists@...> wrote:

>
> 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@..., "thomas_13s" <thomas_13s@> 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.
> >
>



Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by valdhor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you could post some working sample code (With sample data - not with a server call), I could take a look.

--- In flexcoders@..., "thomas_13s" <thomas_13s@...> wrote:

>
> Hi,
> Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> thanks in advance,
> Tom.
>
>
> --- In flexcoders@..., "valdhor" <valdhorlists@> wrote:
> >
> > 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@..., "thomas_13s" <thomas_13s@> 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.
> > >
> >
>



Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

first of all some of my menu has 2 values and some of then have 3  or more values like
label1,url1 and label2 , url2.
I mean my ddArr array Collection [object Object], [object Object], this one value in some cases,below is the sample data and  i tried youe code and it works for the array you had given but how can i do it for this array.
currently dObj.label has the labels and dObj,url has the urls and ddArr has this obj added to.
 
 private var dpSrv:ArrayCollection = new ArrayCollection([
          { Index:"4503599627388358", Service:"Srv1", Priority:"Unspecified", CurrentSLA:"0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production", 
            dd:[{label1:"L1", url1:"u1"} ] },
          { Index:"4503599627371609", Service:"Srv2", Priority:"Unspecified",  CurrentSLA:"1",
            Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production",
            dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
          { Index:"4503599627371606", Service:"Srv3", Priority:"Unspecified",  CurrentSLA:"2",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production", 
           dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
          { Index:"4503599627371607", Service:"Srv4", Priority:"Unspecified",  CurrentSLA:"3",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production", 
            dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
          ]);
  below is the Action Script  code  and mxml i tried for an array like your which work
 
 package
{
    import mx.controls.*;
    import mx.events.MenuEvent ;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import mx.controls.Alert;
   
    public class PopUpMenuButtonRenderer extends PopUpMenuButton
    {
        private var _URL:String;
        private var myMenu:Menu;
        private var popUpB:PopUpMenuButton;
        
      
         public var menuDP:Array = [
            {label: "Google", url: "google.com"},
            {label: "Yahoo", url: "yahoo.com"},
            {label: "Hotmail", url: "hotmail.com"},
            {label: "CA", url: "ca.com"},
            ];
       
        public function PopUpMenuButtonRenderer()
        {
            super();
        }
       
        override public function set data(value:Object) :void
        {
            if(value != null)
            {
           
          //  trace(value["label"], value["url"]);
         
            super.data = value;
                //_URL = value["URL"] ;
                 _URL = value["url"] ;
                addEventListener( MenuEvent.ITEM_CLICK, itemClickHandler)
                label = "Action";
              dataProvider=menuDP;
             // dataProvider=value;
            }
        }
       
               
          public function itemClickHandler(event:MenuEvent):void {
            Alert.show("itemClick event label: " + event.label
                + "  \nindex: " + event.index
                + "  \nitem.label: " + event.item.label
                + "  \nitem.url: " + event.item.url);
               
                 var url:URLRequest;
                 var baseURL:String="";
                                 
                 /* var bidx:int = rURL.indexOf("://");
                  if(        bidx > 0)  {
                    baseURL  =rURL.substring( 0, bidx );
                  }  */
                
                  if (event&&event.item.url != null){
                    url = new URLRequest("http://"+event.item.url);
                     navigateToURL(url, "_blank");
                     }
        }
 
    }
}
 
 
<?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[
      import com.adobe.serialization.json.JSON;
      import flash.events.Event;
      import flash.events.TimerEvent;
      import flash.external.ExternalInterface;
      import flash.utils.Timer;
      import mx.collections.ArrayCollection;
      import mx.controls.AdvancedDataGrid;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
      import mx.controls.Alert;
      import mx.controls.Image;
      import mx.resources.IResourceManager;
      import mx.resources.ResourceManagerImpl;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.advancedDataGridClasses.*;
      import mx.controls.*;
      import mx.events.*;
      import mx.controls.Menu;
  
var dp:ArrayCollection = new ArrayCollection();
        try
        {
          // Xs are the service data, might not be any...
          // XLABEL="Index, Service, Priority, Current SLA, Health, Quality, Risk, Availability [24 hours], Operational Mode, Drill-down"
          var Xs:Array = (tObj.Xs as Array);         
          var xLabels:Array = (Xs[0].label as Array);
          labels = new ArrayCollection(xLabels);  
          var ddLabel:String="";
          var ddUrl:String="";
          var ddData:String="";
          var ddRest:String="";
         
  
          for( var i:uint = 0; i < Xs.length; i++ )
          {
            var xd:Array = (Xs[i].data as Array); 
             var ddArr:ArrayCollection = new ArrayCollection();
                 //ddArr = new ArrayCollection();
            //dp.addItem( { labels.getItemAt(0):xd[0], labels.getItemAt(1):xd[1], labels.getItemAt(2):xd[2],
            //              labels.getItemAt(3):xd[3], labels.getItemAt(4):xd[4], labels.getItemAt(5):xd[5] } );
           if(xd[3]==0)
             xd[3] = "../images/sla_0.png";
            else if(xd[3]==1)
             xd[3] = "../images/sla_1.png";
            else if(xd[3]==2)
             xd[3] = "../images/sla_2.png";
            else if(xd[3]==3)
             xd[3] = "../images/sla_3.png";
            else
             xd[3] = "../images/circleca.png";
           
            if(xd[4]==0)
             xd[4] = "../images/health_0.png";
            else if(xd[4]==1)
             xd[4] = "../images/health_1.png";
            else if(xd[4]==2)
             xd[4] = "../images/health_2.png";
            else if(xd[4]==3)
             xd[4] = "../images/health_3.png";
            else if(xd[4]==4)
             xd[4] = "../images/health_4.png";
            else if(xd[4]==5)
             xd[4] = "../images/health_5.png";
            else
             xd[4] = "../images/circleca.png";

            if(xd[5]==0)
             xd[5] = "../images/quality_0.png";
            else if(xd[5]==1)
             xd[5] = "../images/quality_1.png";
            else if(xd[5]==2)
             xd[5] = "../images/quality_2.png";
            else if(xd[5]==3)
             xd[5] = "../images/quality_3.png";
            else if(xd[5]==4)
             xd[5] = "../images/quality_4.png";
            else if(xd[5]==5)
             xd[5] = "../images/quality_5.png";
            else
             xd[5] = "../images/circleca.png";

            if(xd[6]==0)
             xd[6] = "../images/risk_0.png";
            else if(xd[6]==1)
             xd[6] = "../images/risk_1.png";
            else if(xd[6]==2)
             xd[6] = "../images/risk_2.png";
            else if(xd[6]==3)
             xd[6] = "../images/risk_3.png";
            else if(xd[6]==4)
             xd[6] = "../images/risk_4.png";
            else if(xd[6]==5)
             xd[6] = "../images/risk_5.png";
            else
             xd[6] = "../images/circleca.png";
               
               ddData=  xd[9];
               ddRest=ddData;
          var ddidx:int = ddData.indexOf("|"); 
              
               while ( ddidx > 0 )
               {
              
                   ddLabel= ddRest.substring( 0, ddidx );
                 
                   ddRest= ddRest.substring(ddidx + 1  );
                    ddidx = ddRest.indexOf("|");
                  if(       ddidx > 0)
                   {
                    ddUrl= ddRest.substring(0, ddidx   ); 
                    ddRest= ddRest.substring(ddidx + 1  );
                    ddidx = ddRest.indexOf("|");
                   }
              
                  dObj.label=  ddLabel;
                  dObj.url=    ddUrl; 
                  ddArr.addItem(dObj);
              
               }
                           
             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":ddArr} );
             }
        
        }
        catch( error:Error )
        {
          Alert.show( "Error handling service data!" );
          //labels = new ArrayCollection( [ "Status", "Alarms", "Icon", "Open", "Comment", "Last" ] );
          dp = dpSrv;
        }
       // srvTable.dataProvider = dp; 
       gc.source=dp;  
       gc.refresh();
      
       
      }

 
    ]]>
                 
               
  </mx:Script>
<mx:HTTPService id="sst" resultFormat="text" result="onJSONLoad(event)" url="{sURL}" fault="onFaultLoad(event)"/>
  <mx:Panel id="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="Service" />
                        </mx:Grouping>
                    </mx:grouping>
                </mx:GroupingCollection> 
             </mx:dataProvider>    
           
            <mx:columns>
              
                <mx:AdvancedDataGridColumn dataField="Service" headerText="Service"/>
                <mx:AdvancedDataGridColumn  dataField="Priority" headerText="Priority"/>
                <mx:AdvancedDataGridColumn  id ="csla" dataField="Current SLA"  headerText="Current SLA" width="85" textAlign="center" sortable="true"/>
                <mx:AdvancedDataGridColumn id="hlth" dataField="Health"  headerText="Health" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"  headerText="Quality" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"  headerText="Risk" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn dataField="Avail"  headerText="Availability [24 hours]" width="85" textAlign="right"/>
                <mx:AdvancedDataGridColumn dataField="OpMode"  headerText="Operational Mode" width="200" textAlign="left"/>
                <mx:AdvancedDataGridColumn id ="ddcol" dataField="dd"  headerText=" Drill-down" width="200" textAlign="left"/> <!--itemRenderer="mx.controls.PopUpButton"-->
            
             </mx:columns>
             <mx:rendererProviders>   
             <mx:AdvancedDataGridRendererProvider dataField="Current SLA" depth="2"  column="{csla}" columnIndex="2"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Health" depth="2" column="{hlth}" columnIndex="3"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Quality" depth="2"  column="{qlty}" columnIndex="4"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Risk" depth="2"  column="{rsk}" columnIndex="5"
             renderer="mx.controls.Image" />
            <!--<mx:AdvancedDataGridRendererProvider dataField="dd" depth="2" column="{ddcol}"  columnIndex="8"
             renderer="mx.controls.PopUpButton" />-->
              <mx:AdvancedDataGridRendererProvider  column="{ddcol} " depth="2" renderer="PopUpMenuButtonRenderer" />
 
          </mx:rendererProviders>
       </mx:AdvancedDataGrid>
          
  
  </mx:Panel>
</mx:Application>
 
 
Thanks in advance,
Tom.

--- On Wed, 11/4/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Wednesday, November 4, 2009, 9:20 PM


 



If you could post some working sample code (With sample data - not with a server call), I could take a look.

--- In flexcoders@yahoogro ups.com, "thomas_13s" <thomas_13s@ ...> wrote:

>
> Hi,
> Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> thanks in advance,
> Tom.
>
>
> --- In flexcoders@yahoogro ups.com, "valdhor" <valdhorlists@ > wrote:
> >
> > 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:AdvancedDataGri d width="100%" height="100% ">
> > <mx:dataProvider>
> > <mx:HierarchicalDat a source="{dpHierarch y}"/>
> > </mx:dataProvider>
> > <mx:columns>
> > <mx:AdvancedDataGri dColumn dataField="Region" />
> > <mx:AdvancedDataGri dColumn dataField="Territor y_Rep"
> > headerText=" Territory Rep"/>
> > <mx:AdvancedDataGri dColumn dataField="Actual" />
> > <mx:AdvancedDataGri dColumn dataField="Estimate "/>
> > <mx:AdvancedDataGri dColumn id="actionCol"
> > headerText=" Action"/>
> > </mx:columns>
> > <mx:rendererProvide rs>
> > <mx:AdvancedDataGri dRendererProvide r column="{actionCol} "
> > depth="3" renderer="PopUpMenu ButtonRenderer" />
> > </mx:rendererProvid ers>
> > </mx:AdvancedDataGr id>
> > </mx:Application>
> >
> > PopUpMenuButtonRend erer.as:
> > package
> > {
> > import mx.controls. *;
> > import mx.events.MenuEvent ;
> > import flash.net.URLReques t;
> > import flash.net.navigateT oURL;
> >
> > public class PopUpMenuButtonRend erer extends PopUpMenuButton
> > {
> > private var _URL:String;
> > private static const menuItems:Array = ["Go to Web Site", "Do
> > Something Else"];
> >
> > public function PopUpMenuButtonRend erer()
> > {
> > 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@yahoogro ups.com, "thomas_13s" <thomas_13s@ > 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= "onCreationCompl ete();">
> > > <mx:Style>
> > > .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
> > align:center; }
> > > </mx:Style>
> > > <mx:Script>
> > > <![CDATA[
> > >
> > > var ddArr:ArrayCollecti on = new ArrayCollection( );
> > > var dp:ArrayCollection = new ArrayCollection( );
> > >
> > > var ddLabel:String= "";
> > > var ddUrl:String= "";
> > > var ddData:String= "";
> > > var ddRest:String= "";
> > > var popUpB:PopUpMenuBut ton;
> > >
> > >
> > >
> > > 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.selectedInde x = 0;
> > > myMenu.dataProvider = ddArr;
> > >
> > > // myMenu.addEventList ener("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:AdvancedDataGri d id="srvTable" width="100%" height="100% "
> > color="0x323232" dragEnabled= "true" dropEnabled= "true"
> > > enabled="true" showHeaders= "true"
> > > displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false"
> > initialize=" gc.refresh( );" >
> > > <mx:dataProvider>
> > > <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
> > > <mx:grouping>
> > > <mx:Grouping>
> > > <!-- <mx:GroupingField name="PService" />
> > -->
> > > <mx:GroupingField name="Service" />
> > > </mx:Grouping>
> > > </mx:grouping>
> > > </mx:GroupingCollec tion>
> > > <!-- <mx:HierarchicalDat a id="gc" source="{dpSrv} "/>
> > -->
> > > </mx:dataProvider>
> > >
> > > <mx:columns>
> > >
> > > <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd" headerText="
> > Drill-down" width="200" textAlign="left" >
> > >
> > > </mx:AdvancedDataGr idColumn>
> > >
> > > </mx:columns>
> > >
> > > <mx:rendererProvide rs>
> > > <mx:AdvancedDataGri dRendererProvide r dataField="dd"
> > depth="1" column="{ddcol} " columnIndex= "8"
> > > renderer="mx. controls. PopUpMenuButton" />
> > > </mx:rendererProvid ers>
> > > </mx:AdvancedDataGr id>
> > > </mx:Panel>
> > > </mx:Application>
> > >
> > > thanks in advance,
> > > Tom.
> > >
> >
>















Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by valdhor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

If you want me to take a look, you are going to have to clean up your code. I need something that will work standalone (Like my example). Your code won't even compile. I'm not here to do your work for you.

--- In flexcoders@..., Thomas Silvester <thomas_13s@...> wrote:

>
> first of all some of my menu has 2 values and some of then have 3  or more values like
> label1,url1 and label2 , url2.
> I mean my ddArr array Collection [object Object], [object Object], this one value in some cases,below is the sample data and  i tried youe code and it works for the array you had given but how can i do it for this array.
> currently dObj.label has the labels and dObj,url has the urls and ddArr has this obj added to.
>  
>  private var dpSrv:ArrayCollection = new ArrayCollection([
>           { Index:"4503599627388358", Service:"Srv1", Priority:"Unspecified", CurrentSLA:"0",
>             Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production", 
>             dd:[{label1:"L1", url1:"u1"} ] },
>           { Index:"4503599627371609", Service:"Srv2", Priority:"Unspecified",  CurrentSLA:"1",
>             Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production",
>             dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
>           { Index:"4503599627371606", Service:"Srv3", Priority:"Unspecified",  CurrentSLA:"2",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production", 
>            dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
>           { Index:"4503599627371607", Service:"Srv4", Priority:"Unspecified",  CurrentSLA:"3",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production", 
>             dd:[{label1:"L1", url1:"u1"},{label2:"L2", url2:"u2"} ] },
>           ]);
>   below is the Action Script  code  and mxml i tried for an array like your which work
>  
>  package
> {
>     import mx.controls.*;
>     import mx.events.MenuEvent ;
>     import flash.net.URLRequest;
>     import flash.net.navigateToURL;
>     import mx.controls.Alert;
>    
>     public class PopUpMenuButtonRenderer extends PopUpMenuButton
>     {
>         private var _URL:String;
>         private var myMenu:Menu;
>         private var popUpB:PopUpMenuButton;
>         
>       
>          public var menuDP:Array = [
>             {label: "Google", url: "google.com"},
>             {label: "Yahoo", url: "yahoo.com"},
>             {label: "Hotmail", url: "hotmail.com"},
>             {label: "CA", url: "ca.com"},
>             ];
>        
>         public function PopUpMenuButtonRenderer()
>         {
>             super();
>         }
>        
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {
>            
>           //  trace(value["label"], value["url"]);
>          
>             super.data = value;
>                 //_URL = value["URL"] ;
>                  _URL = value["url"] ;
>                 addEventListener( MenuEvent.ITEM_CLICK, itemClickHandler)
>                 label = "Action";
>               dataProvider=menuDP;
>              // dataProvider=value;
>             }
>         }
>        
>                
>           public function itemClickHandler(event:MenuEvent):void {
>             Alert.show("itemClick event label: " + event.label
>                 + "  \nindex: " + event.index
>                 + "  \nitem.label: " + event.item.label
>                 + "  \nitem.url: " + event.item.url);
>                
>                  var url:URLRequest;
>                  var baseURL:String="";
>                                  
>                  /* var bidx:int = rURL.indexOf("://");
>                   if(        bidx > 0)  {
>                     baseURL  =rURL.substring( 0, bidx );
>                   }  */
>                 
>                   if (event&&event.item.url != null){
>                     url = new URLRequest("http://"+event.item.url);
>                      navigateToURL(url, "_blank");
>                      }
>         }
>  
>     }
> }
>  
>  
> <?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[
>       import com.adobe.serialization.json.JSON;
>       import flash.events.Event;
>       import flash.events.TimerEvent;
>       import flash.external.ExternalInterface;
>       import flash.utils.Timer;
>       import mx.collections.ArrayCollection;
>       import mx.controls.AdvancedDataGrid;
>       import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
>       import mx.controls.Alert;
>       import mx.controls.Image;
>       import mx.resources.IResourceManager;
>       import mx.resources.ResourceManagerImpl;
>       import mx.rpc.events.ResultEvent;
>       import mx.rpc.events.FaultEvent;
>       import mx.controls.advancedDataGridClasses.*;
>       import mx.controls.*;
>       import mx.events.*;
>       import mx.controls.Menu;
>   
> var dp:ArrayCollection = new ArrayCollection();
>         try
>         {
>           // Xs are the service data, might not be any...
>           // XLABEL="Index, Service, Priority, Current SLA, Health, Quality, Risk, Availability [24 hours], Operational Mode, Drill-down"
>           var Xs:Array = (tObj.Xs as Array);         
>           var xLabels:Array = (Xs[0].label as Array);
>           labels = new ArrayCollection(xLabels);  
>           var ddLabel:String="";
>           var ddUrl:String="";
>           var ddData:String="";
>           var ddRest:String="";
>          
>   
>           for( var i:uint = 0; i < Xs.length; i++ )
>           {
>             var xd:Array = (Xs[i].data as Array); 
>              var ddArr:ArrayCollection = new ArrayCollection();
>                  //ddArr = new ArrayCollection();
>             //dp.addItem( { labels.getItemAt(0):xd[0], labels.getItemAt(1):xd[1], labels.getItemAt(2):xd[2],
>             //              labels.getItemAt(3):xd[3], labels.getItemAt(4):xd[4], labels.getItemAt(5):xd[5] } );
>            if(xd[3]==0)
>              xd[3] = "../images/sla_0.png";
>             else if(xd[3]==1)
>              xd[3] = "../images/sla_1.png";
>             else if(xd[3]==2)
>              xd[3] = "../images/sla_2.png";
>             else if(xd[3]==3)
>              xd[3] = "../images/sla_3.png";
>             else
>              xd[3] = "../images/circleca.png";
>            
>             if(xd[4]==0)
>              xd[4] = "../images/health_0.png";
>             else if(xd[4]==1)
>              xd[4] = "../images/health_1.png";
>             else if(xd[4]==2)
>              xd[4] = "../images/health_2.png";
>             else if(xd[4]==3)
>              xd[4] = "../images/health_3.png";
>             else if(xd[4]==4)
>              xd[4] = "../images/health_4.png";
>             else if(xd[4]==5)
>              xd[4] = "../images/health_5.png";
>             else
>              xd[4] = "../images/circleca.png";
>
>             if(xd[5]==0)
>              xd[5] = "../images/quality_0.png";
>             else if(xd[5]==1)
>              xd[5] = "../images/quality_1.png";
>             else if(xd[5]==2)
>              xd[5] = "../images/quality_2.png";
>             else if(xd[5]==3)
>              xd[5] = "../images/quality_3.png";
>             else if(xd[5]==4)
>              xd[5] = "../images/quality_4.png";
>             else if(xd[5]==5)
>              xd[5] = "../images/quality_5.png";
>             else
>              xd[5] = "../images/circleca.png";
>
>             if(xd[6]==0)
>              xd[6] = "../images/risk_0.png";
>             else if(xd[6]==1)
>              xd[6] = "../images/risk_1.png";
>             else if(xd[6]==2)
>              xd[6] = "../images/risk_2.png";
>             else if(xd[6]==3)
>              xd[6] = "../images/risk_3.png";
>             else if(xd[6]==4)
>              xd[6] = "../images/risk_4.png";
>             else if(xd[6]==5)
>              xd[6] = "../images/risk_5.png";
>             else
>              xd[6] = "../images/circleca.png";
>                
>                ddData=  xd[9];
>                ddRest=ddData;
>           var ddidx:int = ddData.indexOf("|"); 
>               
>                while ( ddidx > 0 )
>                {
>               
>                    ddLabel= ddRest.substring( 0, ddidx );
>                  
>                    ddRest= ddRest.substring(ddidx + 1  );
>                     ddidx = ddRest.indexOf("|");
>                   if(       ddidx > 0)
>                    {
>                     ddUrl= ddRest.substring(0, ddidx   ); 
>                     ddRest= ddRest.substring(ddidx + 1  );
>                     ddidx = ddRest.indexOf("|");
>                    }
>               
>                   dObj.label=  ddLabel;
>                   dObj.url=    ddUrl; 
>                   ddArr.addItem(dObj);
>               
>                }
>                            
>              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":ddArr} );
>              }
>         
>         }
>         catch( error:Error )
>         {
>           Alert.show( "Error handling service data!" );
>           //labels = new ArrayCollection( [ "Status", "Alarms", "Icon", "Open", "Comment", "Last" ] );
>           dp = dpSrv;
>         }
>        // srvTable.dataProvider = dp; 
>        gc.source=dp;  
>        gc.refresh();
>       
>        
>       }
>
>  
>     ]]>
>                  
>                
>   </mx:Script>
> <mx:HTTPService id="sst" resultFormat="text" result="onJSONLoad(event)" url="{sURL}" fault="onFaultLoad(event)"/>
>   <mx:Panel id="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="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollection> 
>              </mx:dataProvider>    
>            
>             <mx:columns>
>               
>                 <mx:AdvancedDataGridColumn dataField="Service" headerText="Service"/>
>                 <mx:AdvancedDataGridColumn  dataField="Priority" headerText="Priority"/>
>                 <mx:AdvancedDataGridColumn  id ="csla" dataField="Current SLA"  headerText="Current SLA" width="85" textAlign="center" sortable="true"/>
>                 <mx:AdvancedDataGridColumn id="hlth" dataField="Health"  headerText="Health" width="85" textAlign="center"  sortable="true"/>
>                 <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"  headerText="Quality" width="85" textAlign="center"  sortable="true"/>
>                 <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"  headerText="Risk" width="85" textAlign="center"  sortable="true"/>
>                 <mx:AdvancedDataGridColumn dataField="Avail"  headerText="Availability [24 hours]" width="85" textAlign="right"/>
>                 <mx:AdvancedDataGridColumn dataField="OpMode"  headerText="Operational Mode" width="200" textAlign="left"/>
>                 <mx:AdvancedDataGridColumn id ="ddcol" dataField="dd"  headerText=" Drill-down" width="200" textAlign="left"/> <!--itemRenderer="mx.controls.PopUpButton"-->
>             
>              </mx:columns>
>              <mx:rendererProviders>   
>              <mx:AdvancedDataGridRendererProvider dataField="Current SLA" depth="2"  column="{csla}" columnIndex="2"
>              renderer="mx.controls.Image" />
>              <mx:AdvancedDataGridRendererProvider dataField="Health" depth="2" column="{hlth}" columnIndex="3"
>              renderer="mx.controls.Image" />
>              <mx:AdvancedDataGridRendererProvider dataField="Quality" depth="2"  column="{qlty}" columnIndex="4"
>              renderer="mx.controls.Image" />
>              <mx:AdvancedDataGridRendererProvider dataField="Risk" depth="2"  column="{rsk}" columnIndex="5"
>              renderer="mx.controls.Image" />
>             <!--<mx:AdvancedDataGridRendererProvider dataField="dd" depth="2" column="{ddcol}"  columnIndex="8"
>              renderer="mx.controls.PopUpButton" />-->
>               <mx:AdvancedDataGridRendererProvider  column="{ddcol} " depth="2" renderer="PopUpMenuButtonRenderer" />
>  
>           </mx:rendererProviders>
>        </mx:AdvancedDataGrid>
>           
>   
>   </mx:Panel>
> </mx:Application>
>  
>  
> Thanks in advance,
> Tom.
>
> --- On Wed, 11/4/09, valdhor <valdhorlists@...> wrote:
>
>
> From: valdhor <valdhorlists@...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
> To: flexcoders@...
> Date: Wednesday, November 4, 2009, 9:20 PM
>
>
>  
>
>
>
> If you could post some working sample code (With sample data - not with a server call), I could take a look.
>
> --- In flexcoders@yahoogro ups.com, "thomas_13s" <thomas_13s@ ...> wrote:
> >
> > Hi,
> > Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> > thanks in advance,
> > Tom.
> >
> >
> > --- In flexcoders@yahoogro ups.com, "valdhor" <valdhorlists@ > wrote:
> > >
> > > 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:AdvancedDataGri d width="100%" height="100% ">
> > > <mx:dataProvider>
> > > <mx:HierarchicalDat a source="{dpHierarch y}"/>
> > > </mx:dataProvider>
> > > <mx:columns>
> > > <mx:AdvancedDataGri dColumn dataField="Region" />
> > > <mx:AdvancedDataGri dColumn dataField="Territor y_Rep"
> > > headerText=" Territory Rep"/>
> > > <mx:AdvancedDataGri dColumn dataField="Actual" />
> > > <mx:AdvancedDataGri dColumn dataField="Estimate "/>
> > > <mx:AdvancedDataGri dColumn id="actionCol"
> > > headerText=" Action"/>
> > > </mx:columns>
> > > <mx:rendererProvide rs>
> > > <mx:AdvancedDataGri dRendererProvide r column="{actionCol} "
> > > depth="3" renderer="PopUpMenu ButtonRenderer" />
> > > </mx:rendererProvid ers>
> > > </mx:AdvancedDataGr id>
> > > </mx:Application>
> > >
> > > PopUpMenuButtonRend erer.as:
> > > package
> > > {
> > > import mx.controls. *;
> > > import mx.events.MenuEvent ;
> > > import flash.net.URLReques t;
> > > import flash.net.navigateT oURL;
> > >
> > > public class PopUpMenuButtonRend erer extends PopUpMenuButton
> > > {
> > > private var _URL:String;
> > > private static const menuItems:Array = ["Go to Web Site", "Do
> > > Something Else"];
> > >
> > > public function PopUpMenuButtonRend erer()
> > > {
> > > 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@yahoogro ups.com, "thomas_13s" <thomas_13s@ > 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= "onCreationCompl ete();">
> > > > <mx:Style>
> > > > .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
> > > align:center; }
> > > > </mx:Style>
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > var ddArr:ArrayCollecti on = new ArrayCollection( );
> > > > var dp:ArrayCollection = new ArrayCollection( );
> > > >
> > > > var ddLabel:String= "";
> > > > var ddUrl:String= "";
> > > > var ddData:String= "";
> > > > var ddRest:String= "";
> > > > var popUpB:PopUpMenuBut ton;
> > > >
> > > >
> > > >
> > > > 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.selectedInde x = 0;
> > > > myMenu.dataProvider = ddArr;
> > > >
> > > > // myMenu.addEventList ener("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:AdvancedDataGri d id="srvTable" width="100%" height="100% "
> > > color="0x323232" dragEnabled= "true" dropEnabled= "true"
> > > > enabled="true" showHeaders= "true"
> > > > displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false"
> > > initialize=" gc.refresh( );" >
> > > > <mx:dataProvider>
> > > > <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
> > > > <mx:grouping>
> > > > <mx:Grouping>
> > > > <!-- <mx:GroupingField name="PService" />
> > > -->
> > > > <mx:GroupingField name="Service" />
> > > > </mx:Grouping>
> > > > </mx:grouping>
> > > > </mx:GroupingCollec tion>
> > > > <!-- <mx:HierarchicalDat a id="gc" source="{dpSrv} "/>
> > > -->
> > > > </mx:dataProvider>
> > > >
> > > > <mx:columns>
> > > >
> > > > <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd" headerText="
> > > Drill-down" width="200" textAlign="left" >
> > > >
> > > > </mx:AdvancedDataGr idColumn>
> > > >
> > > > </mx:columns>
> > > >
> > > > <mx:rendererProvide rs>
> > > > <mx:AdvancedDataGri dRendererProvide r dataField="dd"
> > > depth="1" column="{ddcol} " columnIndex= "8"
> > > > renderer="mx. controls. PopUpMenuButton" />
> > > > </mx:rendererProvid ers>
> > > > </mx:AdvancedDataGr id>
> > > > </mx:Panel>
> > > > </mx:Application>
> > > >
> > > > thanks in advance,
> > > > Tom.
> > > >
> > >
> >
>



Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Sorry for the trouble.
Please give me some clue on how can I get  the objects from the Array of objects in renderer .
  override public function set data(value:Object) :void
        {
            if(value != null)
            {
                super.data = value;
                //_URL = value["URL"] ;
                 _URL = value["url"] ;
                addEventListener( MenuEvent.ITEM_CLICK, itemClickHandler)
                label = "Action";
             // dataProvider=menuDP;
              dataProvider=value;
            }
        }

I mean I have the array of object in my PopUpMenuButtonRenderer.as now as the value. but if I give that as the dataprovider instead of the hardcoded array what i see in my  PopUpMenuButton is {object Object} instead of the real values, how can i get the real values which is the dObj.label and dObj.url  whcih I added to the ddArr.
any help is appreciated.
thanks,
Tom.

--- On Wed, 11/4/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Wednesday, November 4, 2009, 11:50 PM


 



If you want me to take a look, you are going to have to clean up your code. I need something that will work standalone (Like my example). Your code won't even compile. I'm not here to do your work for you.

--- In flexcoders@yahoogro ups.com, Thomas Silvester <thomas_13s@ ...> wrote:

>
> first of all some of my menu has 2 values and some of then have 3  or more values like
> label1,url1 and label2 , url2.
> I mean my ddArr array Collection [object Object], [object Object], this one value in some cases,below is the sample data and  i tried youe code and it works for the array you had given but how can i do it for this array.
> currently dObj.label has the labels and dObj,url has the urls and ddArr has this obj added to.
>  
>  private var dpSrv:ArrayCollecti on = new ArrayCollection( [
>           { Index:"450359962738 8358", Service:"Srv1" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>             Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"} ] },
>           { Index:"450359962737 1609", Service:"Srv2" , Priority:"Unspecifi ed",  CurrentSLA:" 1",
>             Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1606", Service:"Srv3" , Priority:"Unspecifi ed",  CurrentSLA:" 2",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>            dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1607", Service:"Srv4" , Priority:"Unspecifi ed",  CurrentSLA:" 3",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           ]);
>   below is the Action Script  code  and mxml i tried for an array like your which work
>  
>  package
> {
>     import mx.controls. *;
>     import mx.events.MenuEvent ;
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. Alert;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         private var _URL:String;
>         private var myMenu:Menu;
>         private var popUpB:PopUpMenuBut ton;
>         
>       
>          public var menuDP:Array = [
>             {label: "Google", url: "google.com" },
>             {label: "Yahoo", url: "yahoo.com"} ,
>             {label: "Hotmail", url: "hotmail.com" },
>             {label: "CA", url: "ca.com"},
>             ];
>        
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>        
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {
>            
>           //  trace(value[ "label"], value["url"] );
>          
>             super.data = value;
>                 //_URL = value["URL"] ;
>                  _URL = value["url"] ;
>                 addEventListener( MenuEvent.ITEM_ CLICK, itemClickHandler)
>                 label = "Action";
>               dataProvider= menuDP;
>              // dataProvider= value;
>             }
>         }
>        
>                
>           public function itemClickHandler( event:MenuEvent) :void {
>             Alert.show(" itemClick event label: " + event.label
>                 + "  \nindex: " + event.index
>                 + "  \nitem.label: " + event.item.label
>                 + "  \nitem.url: " + event.item.url) ;
>                
>                  var url:URLRequest;
>                  var baseURL:String= "";
>                                  
>                  /* var bidx:int = rURL.indexOf( "://");
>                   if(        bidx > 0)  {
>                     baseURL  =rURL.substring( 0, bidx );
>                   }  */
>                 
>                   if (event&&event. item.url != null){
>                     url = new URLRequest(" http://"+ event.item. url);
>                      navigateToURL( url, "_blank");
>                      }
>         }
>  
>     }
> }
>  
>  
> <?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= "onCreationCompl ete();">
>   <mx:Style>
>     .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12; align:center; }
>   </mx:Style>
>   <mx:Script>
>     <![CDATA[
>       import com.adobe.serializa tion.json. JSON;
>       import flash.events. Event;
>       import flash.events. TimerEvent;
>       import flash.external. ExternalInterfac e;
>       import flash.utils. Timer;
>       import mx.collections. ArrayCollection;
>       import mx.controls. AdvancedDataGrid ;
>       import mx.controls. advancedDataGrid Classes.Advanced DataGridColumn;
>       import mx.controls. Alert;
>       import mx.controls. Image;
>       import mx.resources. IResourceManager ;
>       import mx.resources. ResourceManagerI mpl;
>       import mx.rpc.events. ResultEvent;
>       import mx.rpc.events. FaultEvent;
>       import mx.controls. advancedDataGrid Classes.* ;
>       import mx.controls. *;
>       import mx.events.*;
>       import mx.controls. Menu;
>   
> var dp:ArrayCollection = new ArrayCollection( );
>         try
>         {
>           // Xs are the service data, might not be any...
>           // XLABEL="Index, Service, Priority, Current SLA, Health, Quality, Risk, Availability [24 hours], Operational Mode, Drill-down"
>           var Xs:Array = (tObj.Xs as Array);         
>           var xLabels:Array = (Xs[0].label as Array);
>           labels = new ArrayCollection( xLabels);  
>           var ddLabel:String= "";
>           var ddUrl:String= "";
>           var ddData:String= "";
>           var ddRest:String= "";
>          
>   
>           for( var i:uint = 0; i < Xs.length; i++ )
>           {
>             var xd:Array = (Xs[i].data as Array); 
>              var ddArr:ArrayCollecti on = new ArrayCollection( );
>                  //ddArr = new ArrayCollection( );
>             //dp.addItem( { labels.getItemAt( 0):xd[0], labels.getItemAt( 1):xd[1], labels.getItemAt( 2):xd[2],
>             //              labels.getItemAt( 3):xd[3], labels.getItemAt( 4):xd[4], labels.getItemAt( 5):xd[5] } );
>            if(xd[3]==0)
>              xd[3] = "../images/sla_ 0.png";
>             else if(xd[3]==1)
>              xd[3] = "../images/sla_ 1.png";
>             else if(xd[3]==2)
>              xd[3] = "../images/sla_ 2.png";
>             else if(xd[3]==3)
>              xd[3] = "../images/sla_ 3.png";
>             else
>              xd[3] = "../images/circleca .png";
>            
>             if(xd[4]==0)
>              xd[4] = "../images/health_ 0.png";
>             else if(xd[4]==1)
>              xd[4] = "../images/health_ 1.png";
>             else if(xd[4]==2)
>              xd[4] = "../images/health_ 2.png";
>             else if(xd[4]==3)
>              xd[4] = "../images/health_ 3.png";
>             else if(xd[4]==4)
>              xd[4] = "../images/health_ 4.png";
>             else if(xd[4]==5)
>              xd[4] = "../images/health_ 5.png";
>             else
>              xd[4] = "../images/circleca .png";
>
>             if(xd[5]==0)
>              xd[5] = "../images/quality_ 0.png";
>             else if(xd[5]==1)
>              xd[5] = "../images/quality_ 1.png";
>             else if(xd[5]==2)
>              xd[5] = "../images/quality_ 2.png";
>             else if(xd[5]==3)
>              xd[5] = "../images/quality_ 3.png";
>             else if(xd[5]==4)
>              xd[5] = "../images/quality_ 4.png";
>             else if(xd[5]==5)
>              xd[5] = "../images/quality_ 5.png";
>             else
>              xd[5] = "../images/circleca .png";
>
>             if(xd[6]==0)
>              xd[6] = "../images/risk_ 0.png";
>             else if(xd[6]==1)
>              xd[6] = "../images/risk_ 1.png";
>             else if(xd[6]==2)
>              xd[6] = "../images/risk_ 2.png";
>             else if(xd[6]==3)
>              xd[6] = "../images/risk_ 3.png";
>             else if(xd[6]==4)
>              xd[6] = "../images/risk_ 4.png";
>             else if(xd[6]==5)
>              xd[6] = "../images/risk_ 5.png";
>             else
>              xd[6] = "../images/circleca .png";
>                
>                ddData=  xd[9];
>                ddRest=ddData;
>           var ddidx:int = ddData.indexOf( "|"); 
>               
>                while ( ddidx > 0 )
>                {
>               
>                    ddLabel= ddRest.substring( 0, ddidx );
>                  
>                    ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                   if(       ddidx > 0)
>                    {
>                     ddUrl= ddRest.substring( 0, ddidx   ); 
>                     ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                    }
>               
>                   dObj.label=  ddLabel;
>                   dObj.url=    ddUrl; 
>                   ddArr.addItem( dObj);
>               
>                }
>                            
>              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":ddArr} );
>              }
>         
>         }
>         catch( error:Error )
>         {
>           Alert.show( "Error handling service data!" );
>           //labels = new ArrayCollection( [ "Status", "Alarms", "Icon", "Open", "Comment", "Last" ] );
>           dp = dpSrv;
>         }
>        // srvTable.dataProvid er = dp; 
>        gc.source=dp;  
>        gc.refresh() ;
>       
>        
>       }
>
>  
>     ]]>
>                  
>                
>   </mx:Script>
> <mx:HTTPService id="sst" resultFormat= "text" result="onJSONLoad( event)" url="{sURL}" fault="onFaultLoad( event)"/>
>   <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% " titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF] " >
>                 
> <mx:AdvancedDataGri d id="srvTable" width="100%" height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
>  enabled="true" showHeaders= "true"
> displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );"  > 
>       
>             <mx:dataProvider>
>               <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
>                     <mx:grouping>
>                         <mx:Grouping>
>                          <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollec tion> 
>              </mx:dataProvider>    
>            
>             <mx:columns>
>               
>                 <mx:AdvancedDataGri dColumn dataField="Service" headerText=" Service"/ >
>                 <mx:AdvancedDataGri dColumn  dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGri dColumn  id ="csla" dataField="Current SLA"  headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="hlth" dataField="Health"  headerText=" Health" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="qlty" dataField="Quality"  headerText=" Quality" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="rsk" dataField="Risk"  headerText=" Risk" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn dataField="Avail"  headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGri dColumn dataField="OpMode"  headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd"  headerText=" Drill-down" width="200" textAlign="left" /> <!--itemRenderer= "mx.controls. PopUpButton" -->
>             
>              </mx:columns>
>              <mx:rendererProvide rs>   
>              <mx:AdvancedDataGri dRendererProvide r dataField="Current SLA" depth="2"  column="{csla} " columnIndex= "2"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Health" depth="2" column="{hlth} " columnIndex= "3"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Quality" depth="2"  column="{qlty} " columnIndex= "4"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Risk" depth="2"  column="{rsk} " columnIndex= "5"
>              renderer="mx. controls. Image" />
>             <!--<mx:AdvancedDat aGridRendererPro vider dataField="dd" depth="2" column="{ddcol} "  columnIndex= "8"
>              renderer="mx. controls. PopUpButton" />-->
>               <mx:AdvancedDataGri dRendererProvide r  column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>  
>           </mx:rendererProvid ers>
>        </mx:AdvancedDataGr id>
>           
>   
>   </mx:Panel>
> </mx:Application>
>  
>  
> Thanks in advance,
> Tom.
>
> --- On Wed, 11/4/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
> To: flexcoders@yahoogro ups.com
> Date: Wednesday, November 4, 2009, 9:20 PM
>
>
>  
>
>
>
> If you could post some working sample code (With sample data - not with a server call), I could take a look.
>
> --- In flexcoders@yahoogro ups.com, "thomas_13s" <thomas_13s@ ...> wrote:
> >
> > Hi,
> > Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> > thanks in advance,
> > Tom.
> >
> >
> > --- In flexcoders@yahoogro ups.com, "valdhor" <valdhorlists@ > wrote:
> > >
> > > 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:AdvancedDataGri d width="100%" height="100% ">
> > > <mx:dataProvider>
> > > <mx:HierarchicalDat a source="{dpHierarch y}"/>
> > > </mx:dataProvider>
> > > <mx:columns>
> > > <mx:AdvancedDataGri dColumn dataField="Region" />
> > > <mx:AdvancedDataGri dColumn dataField="Territor y_Rep"
> > > headerText=" Territory Rep"/>
> > > <mx:AdvancedDataGri dColumn dataField="Actual" />
> > > <mx:AdvancedDataGri dColumn dataField="Estimate "/>
> > > <mx:AdvancedDataGri dColumn id="actionCol"
> > > headerText=" Action"/>
> > > </mx:columns>
> > > <mx:rendererProvide rs>
> > > <mx:AdvancedDataGri dRendererProvide r column="{actionCol} "
> > > depth="3" renderer="PopUpMenu ButtonRenderer" />
> > > </mx:rendererProvid ers>
> > > </mx:AdvancedDataGr id>
> > > </mx:Application>
> > >
> > > PopUpMenuButtonRend erer.as:
> > > package
> > > {
> > > import mx.controls. *;
> > > import mx.events.MenuEvent ;
> > > import flash.net.URLReques t;
> > > import flash.net.navigateT oURL;
> > >
> > > public class PopUpMenuButtonRend erer extends PopUpMenuButton
> > > {
> > > private var _URL:String;
> > > private static const menuItems:Array = ["Go to Web Site", "Do
> > > Something Else"];
> > >
> > > public function PopUpMenuButtonRend erer()
> > > {
> > > 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@yahoogro ups.com, "thomas_13s" <thomas_13s@ > 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= "onCreationCompl ete();">
> > > > <mx:Style>
> > > > .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
> > > align:center; }
> > > > </mx:Style>
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > var ddArr:ArrayCollecti on = new ArrayCollection( );
> > > > var dp:ArrayCollection = new ArrayCollection( );
> > > >
> > > > var ddLabel:String= "";
> > > > var ddUrl:String= "";
> > > > var ddData:String= "";
> > > > var ddRest:String= "";
> > > > var popUpB:PopUpMenuBut ton;
> > > >
> > > >
> > > >
> > > > 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.selectedInde x = 0;
> > > > myMenu.dataProvider = ddArr;
> > > >
> > > > // myMenu.addEventList ener("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:AdvancedDataGri d id="srvTable" width="100%" height="100% "
> > > color="0x323232" dragEnabled= "true" dropEnabled= "true"
> > > > enabled="true" showHeaders= "true"
> > > > displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false"
> > > initialize=" gc.refresh( );" >
> > > > <mx:dataProvider>
> > > > <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
> > > > <mx:grouping>
> > > > <mx:Grouping>
> > > > <!-- <mx:GroupingField name="PService" />
> > > -->
> > > > <mx:GroupingField name="Service" />
> > > > </mx:Grouping>
> > > > </mx:grouping>
> > > > </mx:GroupingCollec tion>
> > > > <!-- <mx:HierarchicalDat a id="gc" source="{dpSrv} "/>
> > > -->
> > > > </mx:dataProvider>
> > > >
> > > > <mx:columns>
> > > >
> > > > <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd" headerText="
> > > Drill-down" width="200" textAlign="left" >
> > > >
> > > > </mx:AdvancedDataGr idColumn>
> > > >
> > > > </mx:columns>
> > > >
> > > > <mx:rendererProvide rs>
> > > > <mx:AdvancedDataGri dRendererProvide r dataField="dd"
> > > depth="1" column="{ddcol} " columnIndex= "8"
> > > > renderer="mx. controls. PopUpMenuButton" />
> > > > </mx:rendererProvid ers>
> > > > </mx:AdvancedDataGr id>
> > > > </mx:Panel>
> > > > </mx:Application>
> > > >
> > > > thanks in advance,
> > > > Tom.
> > > >
> > >
> >
>















Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

here is the cleaned one, this is compiling.
 
<?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[
      import com.adobe.serialization.json.JSON;
      import flash.events.Event;
      import flash.events.TimerEvent;
      import flash.external.ExternalInterface;
      import flash.utils.Timer;
      import mx.collections.ArrayCollection;
      import mx.controls.AdvancedDataGrid;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
      import mx.controls.Alert;
      import mx.controls.Image;
      import mx.resources.IResourceManager;
      import mx.resources.ResourceManagerImpl;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.advancedDataGridClasses.*;
      import mx.controls.*;
      import mx.events.*;
      import mx.controls.Menu;
  
 
      [Bindable]
      public var sURL:String="";
    
      [Bindable]
      public var rURL:String = "";
     
      [Bindable]
      public var labels:ArrayCollection = null;
      [Bindable]
      public var cTitle:String = "Services";
      [Bindable]
      public var userid:String = "1";
      [Bindable]
     
      public var dObj:Object=new Object(); 
      private var myTimer:Timer;
      private var delay:uint = 30000;  // Default 30 secs
      private var repcount:uint = 0;
      private var date:Date = new Date();
      [Bindable]
      private var sDate:String = "";
          
      private function initApp( ) : void
      {
        // Do what FlexModuleFactory does, only by hand.
        var rMI:Object = flash.system.ApplicationDomain.currentDomain.getDefinition( "mx.resources.ResourceManagerImpl" );
        mx.core.Singleton.registerClass( "mx.resources.IResourceManager", Class(rMI) );     
      }
      
 
      private function onCreationComplete() : void
      {
     
        var parm:String  = Application.application.parameters.userid;
        if ( (parm != null) && (parm.length > 0) ) userid = parm;
        buildURL( );
       // Alert.show( "URL= " + sURL );
        sst.send();
    
      }
      private function buildURL( ) : void
      { 
    
    
        sURL = "charts/serviceADGTable.swf";      
      }
       private function onFaultLoad( event:FaultEvent ) : void
      {
       Alert.show("onFaultLoad: " + event.fault.message); 
      }
 
     
      private function onJSONLoad( event:ResultEvent ) : void
      {
        var rawData:String = null;
        var bObj:Object = null;
        var tObj:Object = null;
        var myMenu:Menu;
        var dp:ArrayCollection = new ArrayCollection();
        rawData = String( event.result );
        gc.source=dpSrv;  
        gc.refresh();
      
       
      }
        [Bindable]
      public var ddLink2:ArrayCollection = new ArrayCollection([
      { label1:"Google", url1:"http://google.com"},{label2:"yahoo", url2:"http://yahoo.com" }
     
            
      ]);
    [Bindable] 
   public var ddLink1:ArrayCollection = new ArrayCollection([  
     
        { label1:"Hotmail", url1:"http://hotmail.com" }
        ]);
      [Bindable]
     public var dpSrv:ArrayCollection = new ArrayCollection([
          { Index:"4503599627388358", Service:"GAUSU01-BPV-AAAA", Priority:"Unspecified", CurrentSLA:"0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production",
            dd:ddLink2},
          { Index:"4503599627371609", Service:"TestBusinessView", Priority:"Unspecified",  CurrentSLA:"1",
            Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production",
            dd:ddLink2 },
           
          { Index:"4503599627371606", Service:"Sub1BusinessView", Priority:"Unspecified",  CurrentSLA:"2",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production",
             dd:ddLink2 },
          { Index:"4503599627371607", Service:"Sub2BusinessView", Priority:"Unspecified",  CurrentSLA:"3",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production",
            dd:ddLink1}
          ]);
  
    
    ]]>
                 
               
  </mx:Script>
 
  <mx:HTTPService id="sst" resultFormat="text" result="onJSONLoad(event)" url="{sURL}" fault="onFaultLoad(event)"/>
  <mx:Panel id="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="Service" />
                        </mx:Grouping>
                    </mx:grouping>
                </mx:GroupingCollection> 
             </mx:dataProvider>    
           
            <mx:columns>
              
                <mx:AdvancedDataGridColumn dataField="Service" headerText="Service"/>
                <mx:AdvancedDataGridColumn  dataField="Priority" headerText="Priority"/>
                <mx:AdvancedDataGridColumn  id ="csla" dataField="Current SLA"  headerText="Current SLA" width="85" textAlign="center" sortable="true"/>
                <mx:AdvancedDataGridColumn id="hlth" dataField="Health"  headerText="Health" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"  headerText="Quality" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"  headerText="Risk" width="85" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn dataField="Avail"  headerText="Availability [24 hours]" width="85" textAlign="right"/>
                <mx:AdvancedDataGridColumn dataField="OpMode"  headerText="Operational Mode" width="200" textAlign="left"/>
                <mx:AdvancedDataGridColumn id ="ddcol" headerText=" Drill-down" width="200" textAlign="left"/> <!--itemRenderer="mx.controls.PopUpButton"-->
            
             </mx:columns>
             <mx:rendererProviders>   
             <mx:AdvancedDataGridRendererProvider dataField="Current SLA" depth="2"  column="{csla}" columnIndex="2"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Health" depth="2" column="{hlth}" columnIndex="3"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Quality" depth="2"  column="{qlty}" columnIndex="4"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Risk" depth="2"  column="{rsk}" columnIndex="5"
             renderer="mx.controls.Image" />
            <mx:AdvancedDataGridRendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="com.ca.PopUpMenuButtonRenderer" />
           
 
          </mx:rendererProviders>
       </mx:AdvancedDataGrid>
          
  
  </mx:Panel>
</mx:Application>
   Action Script
 
 package
{
    import mx.controls.*;
    import mx.events.MenuEvent ;
    import flash.net.URLRequest;
    import flash.net.navigateToURL;
    import mx.controls.Alert;
    import mx.collections.ArrayCollection;
    public class PopUpMenuButtonRenderer extends PopUpMenuButton
    {
        private var _URL:String;
        private var _DLabel:String;
        private var myMenu:Menu;
        private var popUpB:PopUpMenuButton;
        private var _data:Array = null;
        private var dd_data:ArrayCollection = null;

        
      
         public var menuDP:Array = [
            {label: "Google", url: "google.com"},
            {label: "Yahoo", url: "yahoo.com"},
            {label: "Hotmail", url: "hotmail.com"},
            {label: "CA", url: "ca.com"},
            ];
       
        public function PopUpMenuButtonRenderer()
        {
            super();
        }
       
        override public function set data(value:Object) :void
        {
            if(value != null)
            {
            
               _data = new Array(value);
                 super.data = value;
                //_URL = value["URL"] ;
                 //_URL = value["url"] ;
                           
                //Alert.show("_DLabel="+_DLabel);
                addEventListener( MenuEvent.ITEM_CLICK, itemClickHandler)
                label = "Action";
             // dataProvider=menuDP;
              dataProvider=_data;
            }
        }
       
               
          public function itemClickHandler(event:MenuEvent):void {
            Alert.show("itemClick event label: " + event.label
                + "  \nindex: " + event.index
                + "  \nitem.label: " + event.item.label
                + "  \nitem.url: " + event.item.url);
               
                 var url:URLRequest;
                 var baseURL:String="";
                                 
                 /* var bidx:int = rURL.indexOf("://");
                  if(        bidx > 0)  {
                    baseURL  =rURL.substring( 0, bidx );
                  }  */
                
                  if (event&&event.item.url != null){
                    url = new URLRequest("http://"+event.item.url);
                     navigateToURL(url, "_blank");
                     }
        }
    override public function get data():Object
     {
       return _data;
     }

    }
}
    
                    
  


--- On Thu, 11/5/09, Thomas Silvester <thomas_13s@...> wrote:


From: Thomas Silvester <thomas_13s@...>
Subject: Re: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Thursday, November 5, 2009, 1:20 AM


 








Sorry for the trouble.
Please give me some clue on how can I get  the objects from the Array of objects in renderer .
  override public function set data(value:Object) :void
        {
            if(value != null)
            {
                super.data = value;
                //_URL = value["URL"] ;
                 _URL = value["url"] ;
                addEventListener( MenuEvent.ITEM_ CLICK, itemClickHandler)
                label = "Action";
             // dataProvider= menuDP;
              dataProvider=value;
            }
        }

I mean I have the array of object in my PopUpMenuButtonRend erer.as now as the value. but if I give that as the dataprovider instead of the hardcoded array what i see in my  PopUpMenuButton is {object Object} instead of the real values, how can i get the real values which is the dObj.label and dObj.url  whcih I added to the ddArr.
any help is appreciated.
thanks,
Tom.

--- On Wed, 11/4/09, valdhor <valdhorlists@ embarqmail. com> wrote:


From: valdhor <valdhorlists@ embarqmail. com>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
To: flexcoders@yahoogro ups.com
Date: Wednesday, November 4, 2009, 11:50 PM


 

If you want me to take a look, you are going to have to clean up your code. I need something that will work standalone (Like my example). Your code won't even compile. I'm not here to do your work for you.

--- In flexcoders@yahoogro ups.com, Thomas Silvester <thomas_13s@ ...> wrote:

>
> first of all some of my menu has 2 values and some of then have 3  or more values like
> label1,url1 and label2 , url2.
> I mean my ddArr array Collection [object Object], [object Object], this one value in some cases,below is the sample data and  i tried youe code and it works for the array you had given but how can i do it for this array.
> currently dObj.label has the labels and dObj,url has the urls and ddArr has this obj added to.
>  
>  private var dpSrv:ArrayCollecti on = new ArrayCollection( [
>           { Index:"450359962738 8358", Service:"Srv1" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>             Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"} ] },
>           { Index:"450359962737 1609", Service:"Srv2" , Priority:"Unspecifi ed",  CurrentSLA:" 1",
>             Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1606", Service:"Srv3" , Priority:"Unspecifi ed",  CurrentSLA:" 2",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>            dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1607", Service:"Srv4" , Priority:"Unspecifi ed",  CurrentSLA:" 3",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           ]);
>   below is the Action Script  code  and mxml i tried for an array like your which work
>  
>  package
> {
>     import mx.controls. *;
>     import mx.events.MenuEvent ;
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. Alert;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         private var _URL:String;
>         private var myMenu:Menu;
>         private var popUpB:PopUpMenuBut ton;
>         
>       
>          public var menuDP:Array = [
>             {label: "Google", url: "google.com" },
>             {label: "Yahoo", url: "yahoo.com"} ,
>             {label: "Hotmail", url: "hotmail.com" },
>             {label: "CA", url: "ca.com"},
>             ];
>        
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>        
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {
>            
>           //  trace(value[ "label"], value["url"] );
>          
>             super.data = value;
>                 //_URL = value["URL"] ;
>                  _URL = value["url"] ;
>                 addEventListener( MenuEvent.ITEM_ CLICK, itemClickHandler)
>                 label = "Action";
>               dataProvider= menuDP;
>              // dataProvider= value;
>             }
>         }
>        
>                
>           public function itemClickHandler( event:MenuEvent) :void {
>             Alert.show(" itemClick event label: " + event.label
>                 + "  \nindex: " + event.index
>                 + "  \nitem.label: " + event.item.label
>                 + "  \nitem.url: " + event.item.url) ;
>                
>                  var url:URLRequest;
>                  var baseURL:String= "";
>                                  
>                  /* var bidx:int = rURL.indexOf( "://");
>                   if(        bidx > 0)  {
>                     baseURL  =rURL.substring( 0, bidx );
>                   }  */
>                 
>                   if (event&&event. item.url != null){
>                     url = new URLRequest(" http://"+ event.item. url);
>                      navigateToURL( url, "_blank");
>                      }
>         }
>  
>     }
> }
Please help me out.
thanks,
Tom.
 
 

>  
>  
> <?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= "onCreationCompl ete();">
>   <mx:Style>
>     .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12; align:center; }
>   </mx:Style>
>   <mx:Script>
>     <![CDATA[
>       import com.adobe.serializa tion.json. JSON;
>       import flash.events. Event;
>       import flash.events. TimerEvent;
>       import flash.external. ExternalInterfac e;
>       import flash.utils. Timer;
>       import mx.collections. ArrayCollection;
>       import mx.controls. AdvancedDataGrid ;
>       import mx.controls. advancedDataGrid Classes.Advanced DataGridColumn;
>       import mx.controls. Alert;
>       import mx.controls. Image;
>       import mx.resources. IResourceManager ;
>       import mx.resources. ResourceManagerI mpl;
>       import mx.rpc.events. ResultEvent;
>       import mx.rpc.events. FaultEvent;
>       import mx.controls. advancedDataGrid Classes.* ;
>       import mx.controls. *;
>       import mx.events.*;
>       import mx.controls. Menu;
>   
> var dp:ArrayCollection = new ArrayCollection( );
>         try
>         {
>           // Xs are the service data, might not be any...
>           // XLABEL="Index, Service, Priority, Current SLA, Health, Quality, Risk, Availability [24 hours], Operational Mode, Drill-down"
>           var Xs:Array = (tObj.Xs as Array);         
>           var xLabels:Array = (Xs[0].label as Array);
>           labels = new ArrayCollection( xLabels);  
>           var ddLabel:String= "";
>           var ddUrl:String= "";
>           var ddData:String= "";
>           var ddRest:String= "";
>          
>   
>           for( var i:uint = 0; i < Xs.length; i++ )
>           {
>             var xd:Array = (Xs[i].data as Array); 
>              var ddArr:ArrayCollecti on = new ArrayCollection( );
>                  //ddArr = new ArrayCollection( );
>             //dp.addItem( { labels.getItemAt( 0):xd[0], labels.getItemAt( 1):xd[1], labels.getItemAt( 2):xd[2],
>             //              labels.getItemAt( 3):xd[3], labels.getItemAt( 4):xd[4], labels.getItemAt( 5):xd[5] } );
>            if(xd[3]==0)
>              xd[3] = "../images/sla_ 0.png";
>             else if(xd[3]==1)
>              xd[3] = "../images/sla_ 1.png";
>             else if(xd[3]==2)
>              xd[3] = "../images/sla_ 2.png";
>             else if(xd[3]==3)
>              xd[3] = "../images/sla_ 3.png";
>             else
>              xd[3] = "../images/circleca .png";
>            
>             if(xd[4]==0)
>              xd[4] = "../images/health_ 0.png";
>             else if(xd[4]==1)
>              xd[4] = "../images/health_ 1.png";
>             else if(xd[4]==2)
>              xd[4] = "../images/health_ 2.png";
>             else if(xd[4]==3)
>              xd[4] = "../images/health_ 3.png";
>             else if(xd[4]==4)
>              xd[4] = "../images/health_ 4.png";
>             else if(xd[4]==5)
>              xd[4] = "../images/health_ 5.png";
>             else
>              xd[4] = "../images/circleca .png";
>
>             if(xd[5]==0)
>              xd[5] = "../images/quality_ 0.png";
>             else if(xd[5]==1)
>              xd[5] = "../images/quality_ 1.png";
>             else if(xd[5]==2)
>              xd[5] = "../images/quality_ 2.png";
>             else if(xd[5]==3)
>              xd[5] = "../images/quality_ 3.png";
>             else if(xd[5]==4)
>              xd[5] = "../images/quality_ 4.png";
>             else if(xd[5]==5)
>              xd[5] = "../images/quality_ 5.png";
>             else
>              xd[5] = "../images/circleca .png";
>
>             if(xd[6]==0)
>              xd[6] = "../images/risk_ 0.png";
>             else if(xd[6]==1)
>              xd[6] = "../images/risk_ 1.png";
>             else if(xd[6]==2)
>              xd[6] = "../images/risk_ 2.png";
>             else if(xd[6]==3)
>              xd[6] = "../images/risk_ 3.png";
>             else if(xd[6]==4)
>              xd[6] = "../images/risk_ 4.png";
>             else if(xd[6]==5)
>              xd[6] = "../images/risk_ 5.png";
>             else
>              xd[6] = "../images/circleca .png";
>                
>                ddData=  xd[9];
>                ddRest=ddData;
>           var ddidx:int = ddData.indexOf( "|"); 
>               
>                while ( ddidx > 0 )
>                {
>               
>                    ddLabel= ddRest.substring( 0, ddidx );
>                  
>                    ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                   if(       ddidx > 0)
>                    {
>                     ddUrl= ddRest.substring( 0, ddidx   ); 
>                     ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                    }
>               
>                   dObj.label=  ddLabel;
>                   dObj.url=    ddUrl; 
>                   ddArr.addItem( dObj);
>               
>                }
>                            
>              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":ddArr} );
>              }
>         
>         }
>         catch( error:Error )
>         {
>           Alert.show( "Error handling service data!" );
>           //labels = new ArrayCollection( [ "Status", "Alarms", "Icon", "Open", "Comment", "Last" ] );
>           dp = dpSrv;
>         }
>        // srvTable.dataProvid er = dp; 
>        gc.source=dp;  
>        gc.refresh() ;
>       
>        
>       }
>
>  
>     ]]>
>                  
>                
>   </mx:Script>
> <mx:HTTPService id="sst" resultFormat= "text" result="onJSONLoad( event)" url="{sURL}" fault="onFaultLoad( event)"/>
>   <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% " titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF] " >
>                 
> <mx:AdvancedDataGri d id="srvTable" width="100%" height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
>  enabled="true" showHeaders= "true"
> displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );"  > 
>       
>             <mx:dataProvider>
>               <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
>                     <mx:grouping>
>                         <mx:Grouping>
>                          <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollec tion> 
>              </mx:dataProvider>    
>            
>             <mx:columns>
>               
>                 <mx:AdvancedDataGri dColumn dataField="Service" headerText=" Service"/ >
>                 <mx:AdvancedDataGri dColumn  dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGri dColumn  id ="csla" dataField="Current SLA"  headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="hlth" dataField="Health"  headerText=" Health" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="qlty" dataField="Quality"  headerText=" Quality" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="rsk" dataField="Risk"  headerText=" Risk" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn dataField="Avail"  headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGri dColumn dataField="OpMode"  headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd"  headerText=" Drill-down" width="200" textAlign="left" /> <!--itemRenderer= "mx.controls. PopUpButton" -->
>             
>              </mx:columns>
>              <mx:rendererProvide rs>   
>              <mx:AdvancedDataGri dRendererProvide r dataField="Current SLA" depth="2"  column="{csla} " columnIndex= "2"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Health" depth="2" column="{hlth} " columnIndex= "3"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Quality" depth="2"  column="{qlty} " columnIndex= "4"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Risk" depth="2"  column="{rsk} " columnIndex= "5"
>              renderer="mx. controls. Image" />
>             <!--<mx:AdvancedDat aGridRendererPro vider dataField="dd" depth="2" column="{ddcol} "  columnIndex= "8"
>              renderer="mx. controls. PopUpButton" />-->
>               <mx:AdvancedDataGri dRendererProvide r  column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>  
>           </mx:rendererProvid ers>
>        </mx:AdvancedDataGr id>
>           
>   
>   </mx:Panel>
> </mx:Application>
>  
>  
> Thanks in advance,
> Tom.
>
> --- On Wed, 11/4/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
> To: flexcoders@yahoogro ups.com
> Date: Wednesday, November 4, 2009, 9:20 PM
>
>
>  
>
>
>
> If you could post some working sample code (With sample data - not with a server call), I could take a look.
>
> --- In flexcoders@yahoogro ups.com, "thomas_13s" <thomas_13s@ ...> wrote:
> >
> > Hi,
> > Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> > thanks in advance,
> > Tom.
> >
> >
> > --- In flexcoders@yahoogro ups.com, "valdhor" <valdhorlists@ > wrote:
> > >
> > > 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:AdvancedDataGri d width="100%" height="100% ">
> > > <mx:dataProvider>
> > > <mx:HierarchicalDat a source="{dpHierarch y}"/>
> > > </mx:dataProvider>
> > > <mx:columns>
> > > <mx:AdvancedDataGri dColumn dataField="Region" />
> > > <mx:AdvancedDataGri dColumn dataField="Territor y_Rep"
> > > headerText=" Territory Rep"/>
> > > <mx:AdvancedDataGri dColumn dataField="Actual" />
> > > <mx:AdvancedDataGri dColumn dataField="Estimate "/>
> > > <mx:AdvancedDataGri dColumn id="actionCol"
> > > headerText=" Action"/>
> > > </mx:columns>
> > > <mx:rendererProvide rs>
> > > <mx:AdvancedDataGri dRendererProvide r column="{actionCol} "
> > > depth="3" renderer="PopUpMenu ButtonRenderer" />
> > > </mx:rendererProvid ers>
> > > </mx:AdvancedDataGr id>
> > > </mx:Application>
> > >
> > > PopUpMenuButtonRend erer.as:
> > > package
> > > {
> > > import mx.controls. *;
> > > import mx.events.MenuEvent ;
> > > import flash.net.URLReques t;
> > > import flash.net.navigateT oURL;
> > >
> > > public class PopUpMenuButtonRend erer extends PopUpMenuButton
> > > {
> > > private var _URL:String;
> > > private static const menuItems:Array = ["Go to Web Site", "Do
> > > Something Else"];
> > >
> > > public function PopUpMenuButtonRend erer()
> > > {
> > > 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@yahoogro ups.com, "thomas_13s" <thomas_13s@ > 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= "onCreationCompl ete();">
> > > > <mx:Style>
> > > > .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
> > > align:center; }
> > > > </mx:Style>
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > var ddArr:ArrayCollecti on = new ArrayCollection( );
> > > > var dp:ArrayCollection = new ArrayCollection( );
> > > >
> > > > var ddLabel:String= "";
> > > > var ddUrl:String= "";
> > > > var ddData:String= "";
> > > > var ddRest:String= "";
> > > > var popUpB:PopUpMenuBut ton;
> > > >
> > > >
> > > >
> > > > 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.selectedInde x = 0;
> > > > myMenu.dataProvider = ddArr;
> > > >
> > > > // myMenu.addEventList ener("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:AdvancedDataGri d id="srvTable" width="100%" height="100% "
> > > color="0x323232" dragEnabled= "true" dropEnabled= "true"
> > > > enabled="true" showHeaders= "true"
> > > > displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false"
> > > initialize=" gc.refresh( );" >
> > > > <mx:dataProvider>
> > > > <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
> > > > <mx:grouping>
> > > > <mx:Grouping>
> > > > <!-- <mx:GroupingField name="PService" />
> > > -->
> > > > <mx:GroupingField name="Service" />
> > > > </mx:Grouping>
> > > > </mx:grouping>
> > > > </mx:GroupingCollec tion>
> > > > <!-- <mx:HierarchicalDat a id="gc" source="{dpSrv} "/>
> > > -->
> > > > </mx:dataProvider>
> > > >
> > > > <mx:columns>
> > > >
> > > > <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd" headerText="
> > > Drill-down" width="200" textAlign="left" >
> > > >
> > > > </mx:AdvancedDataGr idColumn>
> > > >
> > > > </mx:columns>
> > > >
> > > > <mx:rendererProvide rs>
> > > > <mx:AdvancedDataGri dRendererProvide r dataField="dd"
> > > depth="1" column="{ddcol} " columnIndex= "8"
> > > > renderer="mx. controls. PopUpMenuButton" />
> > > > </mx:rendererProvid ers>
> > > > </mx:AdvancedDataGr id>
> > > > </mx:Panel>
> > > > </mx:Application>
> > > >
> > > > thanks in advance,
> > > > Tom.
> > > >
> > >
> >
>















Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
Here is the cleaned one, this is compiling.Please help me out.
Thanks,
Tom.
 
<?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= "onCreationCompl ete();">
  <mx:Style>
    .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12; align:center; }
  </mx:Style>
  <mx:Script>
    <![CDATA[
      import com.adobe.serializa tion.json. JSON;
      import flash.events. Event;
      import flash.events. TimerEvent;
      import flash.external. ExternalInterfac e;
      import flash.utils. Timer;
      import mx.collections. ArrayCollection;
      import mx.controls. AdvancedDataGrid ;
      import mx.controls. advancedDataGrid Classes.Advanced DataGridColumn;
      import mx.controls. Alert;
      import mx.controls. Image;
      import mx.resources. IResourceManager ;
      import mx.resources. ResourceManagerI mpl;
      import mx.rpc.events. ResultEvent;
      import mx.rpc.events. FaultEvent;
      import mx.controls. advancedDataGrid Classes.* ;
      import mx.controls. *;
      import mx.events.*;
      import mx.controls. Menu;
  
 
      [Bindable]
      public var sURL:String= "";
    
      [Bindable]
      public var rURL:String = "";
     
      [Bindable]
      public var labels:ArrayCollect ion = null;
      [Bindable]
      public var cTitle:String = "Services";
      [Bindable]
      public var userid:String = "1";
      [Bindable]
     
      public var dObj:Object= new Object(); 
      private var myTimer:Timer;
      private var delay:uint = 30000;  // Default 30 secs
      private var repcount:uint = 0;
      private var date:Date = new Date();
      [Bindable]
      private var sDate:String = "";
          
      private function initApp( ) : void
      {
        // Do what FlexModuleFactory does, only by hand.
        var rMI:Object = flash.system. ApplicationDomai n.currentDomain. getDefinition( "mx.resources. ResourceManagerI mpl" );
        mx.core.Singleton. registerClass( "mx.resources. IResourceManager ", Class(rMI) );     
      }
      
 
      private function onCreationComplete( ) : void
      {
     
        var parm:String  = Application. application. parameters. userid;
        if ( (parm != null) && (parm.length > 0) ) userid = parm;
        buildURL( );
       // Alert.show( "URL= " + sURL );
        sst.send();
    
      }
      private function buildURL( ) : void
      { 
    
    
        sURL = "charts/serviceADGT able.swf" ;      
      }
       private function onFaultLoad( event:FaultEvent ) : void
      {
       Alert.show(" onFaultLoad: " + event.fault. message); 
      }
 
     
      private function onJSONLoad( event:ResultEvent ) : void
      {
        var rawData:String = null;
        var bObj:Object = null;
        var tObj:Object = null;
        var myMenu:Menu;
        var dp:ArrayCollection = new ArrayCollection( );
        rawData = String( event.result );
        gc.source=dpSrv;  
        gc.refresh() ;
      
       
      }
        [Bindable]
      public var ddLink2:ArrayCollec tion = new ArrayCollection( [
      { label1:"Google" , url1:"http://google. com"},{label2: "yahoo", url2:"http://yahoo. com" }
     
            
      ]);
    [Bindable] 
   public var ddLink1:ArrayCollec tion = new ArrayCollection( [  
     
        { label1:"Hotmail" , url1:"http://hotmail. com" }
        ]);
      [Bindable]
     public var dpSrv:ArrayCollecti on = new ArrayCollection( [
          { Index:"450359962738 8358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
            dd:ddLink2},
          { Index:"450359962737 1609", Service:"TestBusine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 1",
            Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
            dd:ddLink2 },
           
          { Index:"450359962737 1606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 2",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
             dd:ddLink2 },
          { Index:"450359962737 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
            dd:ddLink1}
          ]);
  
    
    ]]>
                 
               
  </mx:Script>
 
  <mx:HTTPService id="sst" resultFormat= "text" result="onJSONLoad( event)" url="{sURL}" fault="onFaultLoad( event)"/>
  <mx:Panel id="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"
displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );"  > 
      
            <mx:dataProvider>
              <mx:GroupingCollecti on id="gc" source ="{dpSrv}">
                    <mx:grouping>
                        <mx:Grouping>
                         <mx:GroupingField name="Service" />
                        </mx:Grouping>
                    </mx:grouping>
                </mx:GroupingCollect ion> 
             </mx:dataProvider>    
           
            <mx:columns>
              
                <mx:AdvancedDataGrid Column dataField="Service" headerText=" Service"/>
                <mx:AdvancedDataGrid Column  dataField="Priority " headerText=" Priority" />
                <mx:AdvancedDataGrid Column  id ="csla" dataField="Current SLA"  headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column id="hlth" dataField="Health"  headerText=" Health" width="85" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column id="qlty" dataField="Quality"  headerText=" Quality" width="85" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column id="rsk" dataField="Risk"  headerText=" Risk" width="85" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column dataField="Avail"  headerText=" Availability [24 hours]" width="85" textAlign="right" />
                <mx:AdvancedDataGrid Column dataField="OpMode"  headerText=" Operational Mode" width="200" textAlign="left" />
                <mx:AdvancedDataGrid Column id ="ddcol" headerText=" Drill-down" width="200" textAlign="left" /> <!--itemRenderer= "mx.controls. PopUpButton" -->
            
             </mx:columns>
             <mx:rendererProvider s>   
             <mx:AdvancedDataGrid RendererProvider dataField="Current SLA" depth="2"  column="{csla} " columnIndex= "2"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Quality" depth="2"  column="{qlty} " columnIndex= "4"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Risk" depth="2"  column="{rsk} " columnIndex= "5"
             renderer="mx. controls. Image" />
            <mx:AdvancedDataGrid RendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="com. ca.PopUpMenuButt onRenderer" />
           
 
          </mx:rendererProvide rs>
       </mx:AdvancedDataGri d>
          
  
  </mx:Panel>
</mx:Application>
   Action Script
 
 package
{
    import mx.controls. *;
    import mx.events.MenuEvent ;
    import flash.net.URLReques t;
    import flash.net.navigateT oURL;
    import mx.controls. Alert;
    import mx.collections. ArrayCollection;
    public class PopUpMenuButtonRend erer extends PopUpMenuButton
    {
        private var _URL:String;
        private var _DLabel:String;
        private var myMenu:Menu;
        private var popUpB:PopUpMenuBut ton;
        private var _data:Array = null;
        private var dd_data:ArrayCollec tion = null;

        
      
         public var menuDP:Array = [
            {label: "Google", url: "google.com" },
            {label: "Yahoo", url: "yahoo.com"} ,
            {label: "Hotmail", url: "hotmail.com" },
            {label: "CA", url: "ca.com"},
            ];
       
        public function PopUpMenuButtonRend erer()
        {
            super();
        }
       
        override public function set data(value:Object) :void
        {
            if(value != null)
            {
            
               _data = new Array(value) ;
                 super.data = value;
                //_URL = value["URL"] ;
                 //_URL = value["url"] ;
                           
                //Alert.show( "_DLabel= "+_DLabel) ;
                addEventListener( MenuEvent.ITEM_ CLICK, itemClickHandler)
                label = "Action";
             // dataProvider= menuDP;
              dataProvider= _data;
            }
        }
       
               
          public function itemClickHandler( event:MenuEvent) :void {
            Alert.show(" itemClick event label: " + event.label
                + "  \nindex: " + event.index
                + "  \nitem.label: " + event.item.label
                + "  \nitem.url: " + event.item.url) ;
               
                 var url:URLRequest;
                 var baseURL:String= "";
                                 
                 /* var bidx:int = rURL.indexOf( "://");
                  if(        bidx > 0)  {
                    baseURL  =rURL.substring( 0, bidx );
                  }  */
                
                  if (event&&event.item.url != null){
                    url = new URLRequest("http://"+event. item.url);
                     navigateToURL( url, "_blank");
                     }
        }
    override public function get data():Object
     {
       return _data;
     }

    }
}
    
                    


--- On Wed, 11/4/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Wednesday, November 4, 2009, 11:50 PM


 



If you want me to take a look, you are going to have to clean up your code. I need something that will work standalone (Like my example). Your code won't even compile. I'm not here to do your work for you.

--- In flexcoders@yahoogro ups.com, Thomas Silvester <thomas_13s@ ...> wrote:

>
> first of all some of my menu has 2 values and some of then have 3  or more values like
> label1,url1 and label2 , url2.
> I mean my ddArr array Collection [object Object], [object Object], this one value in some cases,below is the sample data and  i tried youe code and it works for the array you had given but how can i do it for this array.
> currently dObj.label has the labels and dObj,url has the urls and ddArr has this obj added to.
>  
>  private var dpSrv:ArrayCollecti on = new ArrayCollection( [
>           { Index:"450359962738 8358", Service:"Srv1" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>             Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"} ] },
>           { Index:"450359962737 1609", Service:"Srv2" , Priority:"Unspecifi ed",  CurrentSLA:" 1",
>             Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1606", Service:"Srv3" , Priority:"Unspecifi ed",  CurrentSLA:" 2",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>            dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           { Index:"450359962737 1607", Service:"Srv4" , Priority:"Unspecifi ed",  CurrentSLA:" 3",
>             Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" , 
>             dd:[{label1: "L1", url1:"u1"},{ label2:"L2" , url2:"u2"} ] },
>           ]);
>   below is the Action Script  code  and mxml i tried for an array like your which work
>  
>  package
> {
>     import mx.controls. *;
>     import mx.events.MenuEvent ;
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. Alert;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         private var _URL:String;
>         private var myMenu:Menu;
>         private var popUpB:PopUpMenuBut ton;
>         
>       
>          public var menuDP:Array = [
>             {label: "Google", url: "google.com" },
>             {label: "Yahoo", url: "yahoo.com"} ,
>             {label: "Hotmail", url: "hotmail.com" },
>             {label: "CA", url: "ca.com"},
>             ];
>        
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>        
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {
>            
>           //  trace(value[ "label"], value["url"] );
>          
>             super.data = value;
>                 //_URL = value["URL"] ;
>                  _URL = value["url"] ;
>                 addEventListener( MenuEvent.ITEM_ CLICK, itemClickHandler)
>                 label = "Action";
>               dataProvider= menuDP;
>              // dataProvider= value;
>             }
>         }
>        
>                
>           public function itemClickHandler( event:MenuEvent) :void {
>             Alert.show(" itemClick event label: " + event.label
>                 + "  \nindex: " + event.index
>                 + "  \nitem.label: " + event.item.label
>                 + "  \nitem.url: " + event.item.url) ;
>                
>                  var url:URLRequest;
>                  var baseURL:String= "";
>                                  
>                  /* var bidx:int = rURL.indexOf( "://");
>                   if(        bidx > 0)  {
>                     baseURL  =rURL.substring( 0, bidx );
>                   }  */
>                 
>                   if (event&&event. item.url != null){
>                     url = new URLRequest(" http://"+ event.item. url);
>                      navigateToURL( url, "_blank");
>                      }
>         }
>  
>     }
> }
>  
>  
> <?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= "onCreationCompl ete();">
>   <mx:Style>
>     .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12; align:center; }
>   </mx:Style>
>   <mx:Script>
>     <![CDATA[
>       import com.adobe.serializa tion.json. JSON;
>       import flash.events. Event;
>       import flash.events. TimerEvent;
>       import flash.external. ExternalInterfac e;
>       import flash.utils. Timer;
>       import mx.collections. ArrayCollection;
>       import mx.controls. AdvancedDataGrid ;
>       import mx.controls. advancedDataGrid Classes.Advanced DataGridColumn;
>       import mx.controls. Alert;
>       import mx.controls. Image;
>       import mx.resources. IResourceManager ;
>       import mx.resources. ResourceManagerI mpl;
>       import mx.rpc.events. ResultEvent;
>       import mx.rpc.events. FaultEvent;
>       import mx.controls. advancedDataGrid Classes.* ;
>       import mx.controls. *;
>       import mx.events.*;
>       import mx.controls. Menu;
>   
> var dp:ArrayCollection = new ArrayCollection( );
>         try
>         {
>           // Xs are the service data, might not be any...
>           // XLABEL="Index, Service, Priority, Current SLA, Health, Quality, Risk, Availability [24 hours], Operational Mode, Drill-down"
>           var Xs:Array = (tObj.Xs as Array);         
>           var xLabels:Array = (Xs[0].label as Array);
>           labels = new ArrayCollection( xLabels);  
>           var ddLabel:String= "";
>           var ddUrl:String= "";
>           var ddData:String= "";
>           var ddRest:String= "";
>          
>   
>           for( var i:uint = 0; i < Xs.length; i++ )
>           {
>             var xd:Array = (Xs[i].data as Array); 
>              var ddArr:ArrayCollecti on = new ArrayCollection( );
>                  //ddArr = new ArrayCollection( );
>             //dp.addItem( { labels.getItemAt( 0):xd[0], labels.getItemAt( 1):xd[1], labels.getItemAt( 2):xd[2],
>             //              labels.getItemAt( 3):xd[3], labels.getItemAt( 4):xd[4], labels.getItemAt( 5):xd[5] } );
>            if(xd[3]==0)
>              xd[3] = "../images/sla_ 0.png";
>             else if(xd[3]==1)
>              xd[3] = "../images/sla_ 1.png";
>             else if(xd[3]==2)
>              xd[3] = "../images/sla_ 2.png";
>             else if(xd[3]==3)
>              xd[3] = "../images/sla_ 3.png";
>             else
>              xd[3] = "../images/circleca .png";
>            
>             if(xd[4]==0)
>              xd[4] = "../images/health_ 0.png";
>             else if(xd[4]==1)
>              xd[4] = "../images/health_ 1.png";
>             else if(xd[4]==2)
>              xd[4] = "../images/health_ 2.png";
>             else if(xd[4]==3)
>              xd[4] = "../images/health_ 3.png";
>             else if(xd[4]==4)
>              xd[4] = "../images/health_ 4.png";
>             else if(xd[4]==5)
>              xd[4] = "../images/health_ 5.png";
>             else
>              xd[4] = "../images/circleca .png";
>
>             if(xd[5]==0)
>              xd[5] = "../images/quality_ 0.png";
>             else if(xd[5]==1)
>              xd[5] = "../images/quality_ 1.png";
>             else if(xd[5]==2)
>              xd[5] = "../images/quality_ 2.png";
>             else if(xd[5]==3)
>              xd[5] = "../images/quality_ 3.png";
>             else if(xd[5]==4)
>              xd[5] = "../images/quality_ 4.png";
>             else if(xd[5]==5)
>              xd[5] = "../images/quality_ 5.png";
>             else
>              xd[5] = "../images/circleca .png";
>
>             if(xd[6]==0)
>              xd[6] = "../images/risk_ 0.png";
>             else if(xd[6]==1)
>              xd[6] = "../images/risk_ 1.png";
>             else if(xd[6]==2)
>              xd[6] = "../images/risk_ 2.png";
>             else if(xd[6]==3)
>              xd[6] = "../images/risk_ 3.png";
>             else if(xd[6]==4)
>              xd[6] = "../images/risk_ 4.png";
>             else if(xd[6]==5)
>              xd[6] = "../images/risk_ 5.png";
>             else
>              xd[6] = "../images/circleca .png";
>                
>                ddData=  xd[9];
>                ddRest=ddData;
>           var ddidx:int = ddData.indexOf( "|"); 
>               
>                while ( ddidx > 0 )
>                {
>               
>                    ddLabel= ddRest.substring( 0, ddidx );
>                  
>                    ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                   if(       ddidx > 0)
>                    {
>                     ddUrl= ddRest.substring( 0, ddidx   ); 
>                     ddRest= ddRest.substring( ddidx + 1  );
>                     ddidx = ddRest.indexOf( "|");
>                    }
>               
>                   dObj.label=  ddLabel;
>                   dObj.url=    ddUrl; 
>                   ddArr.addItem( dObj);
>               
>                }
>                            
>              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":ddArr} );
>              }
>         
>         }
>         catch( error:Error )
>         {
>           Alert.show( "Error handling service data!" );
>           //labels = new ArrayCollection( [ "Status", "Alarms", "Icon", "Open", "Comment", "Last" ] );
>           dp = dpSrv;
>         }
>        // srvTable.dataProvid er = dp; 
>        gc.source=dp;  
>        gc.refresh() ;
>       
>        
>       }
>
>  
>     ]]>
>                  
>                
>   </mx:Script>
> <mx:HTTPService id="sst" resultFormat= "text" result="onJSONLoad( event)" url="{sURL}" fault="onFaultLoad( event)"/>
>   <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% " titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF] " >
>                 
> <mx:AdvancedDataGri d id="srvTable" width="100%" height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
>  enabled="true" showHeaders= "true"
> displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );"  > 
>       
>             <mx:dataProvider>
>               <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
>                     <mx:grouping>
>                         <mx:Grouping>
>                          <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollec tion> 
>              </mx:dataProvider>    
>            
>             <mx:columns>
>               
>                 <mx:AdvancedDataGri dColumn dataField="Service" headerText=" Service"/ >
>                 <mx:AdvancedDataGri dColumn  dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGri dColumn  id ="csla" dataField="Current SLA"  headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="hlth" dataField="Health"  headerText=" Health" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="qlty" dataField="Quality"  headerText=" Quality" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn id="rsk" dataField="Risk"  headerText=" Risk" width="85" textAlign="center"  sortable="true" />
>                 <mx:AdvancedDataGri dColumn dataField="Avail"  headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGri dColumn dataField="OpMode"  headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd"  headerText=" Drill-down" width="200" textAlign="left" /> <!--itemRenderer= "mx.controls. PopUpButton" -->
>             
>              </mx:columns>
>              <mx:rendererProvide rs>   
>              <mx:AdvancedDataGri dRendererProvide r dataField="Current SLA" depth="2"  column="{csla} " columnIndex= "2"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Health" depth="2" column="{hlth} " columnIndex= "3"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Quality" depth="2"  column="{qlty} " columnIndex= "4"
>              renderer="mx. controls. Image" />
>              <mx:AdvancedDataGri dRendererProvide r dataField="Risk" depth="2"  column="{rsk} " columnIndex= "5"
>              renderer="mx. controls. Image" />
>             <!--<mx:AdvancedDat aGridRendererPro vider dataField="dd" depth="2" column="{ddcol} "  columnIndex= "8"
>              renderer="mx. controls. PopUpButton" />-->
>               <mx:AdvancedDataGri dRendererProvide r  column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>  
>           </mx:rendererProvid ers>
>        </mx:AdvancedDataGr id>
>           
>   
>   </mx:Panel>
> </mx:Application>
>  
>  
> Thanks in advance,
> Tom.
>
> --- On Wed, 11/4/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
> To: flexcoders@yahoogro ups.com
> Date: Wednesday, November 4, 2009, 9:20 PM
>
>
>  
>
>
>
> If you could post some working sample code (With sample data - not with a server call), I could take a look.
>
> --- In flexcoders@yahoogro ups.com, "thomas_13s" <thomas_13s@ ...> wrote:
> >
> > Hi,
> > Thanks a lot.please let me know looking the code i have included how can I show PopUpMenuButton on the Drill-Down column and populate the PUButton with the dObj.label and dObj.url which i ahve added to ddArr now.
> > thanks in advance,
> > Tom.
> >
> >
> > --- In flexcoders@yahoogro ups.com, "valdhor" <valdhorlists@ > wrote:
> > >
> > > 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:AdvancedDataGri d width="100%" height="100% ">
> > > <mx:dataProvider>
> > > <mx:HierarchicalDat a source="{dpHierarch y}"/>
> > > </mx:dataProvider>
> > > <mx:columns>
> > > <mx:AdvancedDataGri dColumn dataField="Region" />
> > > <mx:AdvancedDataGri dColumn dataField="Territor y_Rep"
> > > headerText=" Territory Rep"/>
> > > <mx:AdvancedDataGri dColumn dataField="Actual" />
> > > <mx:AdvancedDataGri dColumn dataField="Estimate "/>
> > > <mx:AdvancedDataGri dColumn id="actionCol"
> > > headerText=" Action"/>
> > > </mx:columns>
> > > <mx:rendererProvide rs>
> > > <mx:AdvancedDataGri dRendererProvide r column="{actionCol} "
> > > depth="3" renderer="PopUpMenu ButtonRenderer" />
> > > </mx:rendererProvid ers>
> > > </mx:AdvancedDataGr id>
> > > </mx:Application>
> > >
> > > PopUpMenuButtonRend erer.as:
> > > package
> > > {
> > > import mx.controls. *;
> > > import mx.events.MenuEvent ;
> > > import flash.net.URLReques t;
> > > import flash.net.navigateT oURL;
> > >
> > > public class PopUpMenuButtonRend erer extends PopUpMenuButton
> > > {
> > > private var _URL:String;
> > > private static const menuItems:Array = ["Go to Web Site", "Do
> > > Something Else"];
> > >
> > > public function PopUpMenuButtonRend erer()
> > > {
> > > 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@yahoogro ups.com, "thomas_13s" <thomas_13s@ > 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= "onCreationCompl ete();">
> > > > <mx:Style>
> > > > .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12;
> > > align:center; }
> > > > </mx:Style>
> > > > <mx:Script>
> > > > <![CDATA[
> > > >
> > > > var ddArr:ArrayCollecti on = new ArrayCollection( );
> > > > var dp:ArrayCollection = new ArrayCollection( );
> > > >
> > > > var ddLabel:String= "";
> > > > var ddUrl:String= "";
> > > > var ddData:String= "";
> > > > var ddRest:String= "";
> > > > var popUpB:PopUpMenuBut ton;
> > > >
> > > >
> > > >
> > > > 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.selectedInde x = 0;
> > > > myMenu.dataProvider = ddArr;
> > > >
> > > > // myMenu.addEventList ener("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:AdvancedDataGri d id="srvTable" width="100%" height="100% "
> > > color="0x323232" dragEnabled= "true" dropEnabled= "true"
> > > > enabled="true" showHeaders= "true"
> > > > displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false"
> > > initialize=" gc.refresh( );" >
> > > > <mx:dataProvider>
> > > > <mx:GroupingCollect ion id="gc" source ="{dpSrv}">
> > > > <mx:grouping>
> > > > <mx:Grouping>
> > > > <!-- <mx:GroupingField name="PService" />
> > > -->
> > > > <mx:GroupingField name="Service" />
> > > > </mx:Grouping>
> > > > </mx:grouping>
> > > > </mx:GroupingCollec tion>
> > > > <!-- <mx:HierarchicalDat a id="gc" source="{dpSrv} "/>
> > > -->
> > > > </mx:dataProvider>
> > > >
> > > > <mx:columns>
> > > >
> > > > <mx:AdvancedDataGri dColumn id ="ddcol" dataField="dd" headerText="
> > > Drill-down" width="200" textAlign="left" >
> > > >
> > > > </mx:AdvancedDataGr idColumn>
> > > >
> > > > </mx:columns>
> > > >
> > > > <mx:rendererProvide rs>
> > > > <mx:AdvancedDataGri dRendererProvide r dataField="dd"
> > > depth="1" column="{ddcol} " columnIndex= "8"
> > > > renderer="mx. controls. PopUpMenuButton" />
> > > > </mx:rendererProvid ers>
> > > > </mx:AdvancedDataGr id>
> > > > </mx:Panel>
> > > > </mx:Application>
> > > >
> > > > thanks in advance,
> > > > Tom.
> > > >
> > >
> >
>















Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by valdhor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Actually, you were relatively close. If you had put a breakpoint in the
set data function of the renderer, you should have seen the data you
needed.

Anyway, here is a cleaned up version that works as you intended:

<?xml version="1.0" encoding="utf-8"?>
<!-- Dashboard Main Service Summary table -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="100%"
height="100%" backgroundColor="#FFFFFF">
     <mx:Style>
         .hStyle {fontWeight:bold; fontFamily:Verdana; fontSize:12;
align:center;}
     </mx:Style>
     <mx:Script>
         <![CDATA[
             import mx.collections.ArrayCollection;

             [Bindable] public var cTitle:String = "Services";
             [Bindable] public var ddLink2:ArrayCollection = new
ArrayCollection([
                 {label:"Google",
url:"http://google.com"},{label:"yahoo", url:"http://yahoo.com"}
             ]);
             [Bindable] public var ddLink1:ArrayCollection = new
ArrayCollection([
                 {label:"Hotmail", url:"http://hotmail.com"}
             ]);
             [Bindable] public var dpSrv:ArrayCollection = new
ArrayCollection([
                 {Index:"4503599627388358", Service:"GAUSU01-BPV-AAAA" ,
Priority:"Unspecified", CurrentSLA:" 0",
                 Health:"3", Quality:"0", Risk:"3", Avail:"0%",
OpMode:"Production",
                 dd:ddLink2},
                 {Index:"4503599627371609", Service:"TestBusinessView",
Priority:"Unspecified", CurrentSLA:" 1",
                 Health:"2", Quality:"0", Risk:"2", Avail:"0%",
OpMode:"Production",
                 dd:ddLink2},
                 {Index:"4503599627371606", Service:"Sub1BusinessView",
Priority:"Unspecified", CurrentSLA:" 2",
                 Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production" ,
                 dd:ddLink2},
                 {Index:"450359962737 1607", Service:"Sub2BusinessView",
Priority:"Unspecified",  CurrentSLA:" 3",
                 Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production",
                 dd:ddLink1}
             ]);
         ]]>
     </mx:Script>
     <mx:Panel id="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="Service"/>
                         </mx:Grouping>
                     </mx:grouping>
                 </mx:GroupingCollection>
             </mx:dataProvider>
             <mx:columns>
                 <mx:AdvancedDataGridColumn dataField="Service"
headerText="Service"/>
                 <mx:AdvancedDataGridColumn dataField="Priority"
headerText="Priority" />
                 <mx:AdvancedDataGridColumn id="csla" dataField="Current
SLA" headerText="Current SLA" width="85" textAlign="center"
sortable="true"/>
                 <mx:AdvancedDataGridColumn id="hlth" dataField="Health"
headerText=" Health" width="85" textAlign="center" sortable="true"/>
                 <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"
headerText=" Quality" width="85" textAlign="center" sortable="true"/>
                 <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"
headerText="Risk" width="85" textAlign="center" sortable="true"/>
                 <mx:AdvancedDataGridColumn dataField="Avail"
headerText="Availability [24 hours]" width="85" textAlign="right"/>
                 <mx:AdvancedDataGridColumn dataField="OpMode"
headerText="Operational Mode" width="200" textAlign="left"/>
                 <mx:AdvancedDataGridColumn id="ddcol"
headerText="Drill-down" width="200" textAlign="left" />
             </mx:columns>
             <mx:rendererProviders>
                 <mx:AdvancedDataGridRendererProvider dataField="Current
SLA" depth="2" column="{csla}" columnIndex="2"
renderer="mx.controls.Image" />
                 <mx:AdvancedDataGridRendererProvider dataField="Health"
depth="2" column="{hlth}" columnIndex="3" renderer="mx.controls.Image"
/>
                 <mx:AdvancedDataGridRendererProvider dataField="Quality"
depth="2" column="{qlty}" columnIndex="4" renderer="mx.controls.Image"
/>
                 <mx:AdvancedDataGridRendererProvider dataField="Risk"
depth="2" column="{rsk}" columnIndex="5" renderer="mx.controls.Image" />
                 <mx:AdvancedDataGridRendererProvider dataField="dd"
column="{ddcol}" depth="2" renderer="PopUpMenuButtonRenderer" />
             </mx:rendererProviders>
         </mx:AdvancedDataGrid>
     </mx:Panel>
</mx:Application>



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

     public class PopUpMenuButtonRenderer extends PopUpMenuButton
     {
         public function PopUpMenuButtonRenderer()
         {
             super();
         }

         override public function set data(value:Object):void
         {
             if(value != null)
             {
                 super.data = value;
                 addEventListener(MenuEvent.ITEM_CLICK,
itemClickHandler);
                 label = "Action";
                 dataProvider = value.dd;
                 labelField = "label";
             }
         }

         public function itemClickHandler(event:MenuEvent):void
         {
             if(event && event.item.url != null)
             {
                 navigateToURL(new URLRequest(event.item.url), "_blank");
             }
         }
     }
}


HTH




Steve


Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks a lot, I am not working in a Flex builder environment, i am compiling from Cmd line.
thanks,
Tom.

--- On Thu, 11/5/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Thursday, November 5, 2009, 8:40 PM


 



Actually, you were relatively close. If you had put a breakpoint in the set data function of the renderer, you should have seen the data you needed.

Anyway, here is a cleaned up version that works as you intended:

<?xml version="1.0" encoding="utf- 8"?>
<!-- Dashboard Main Service Summary table -->
<mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" width="100%" height="100% " backgroundColor= "#FFFFFF">
    <mx:Style>
        .hStyle {fontWeight: bold; fontFamily:Verdana; fontSize:12; align:center; }
    </mx:Style>
    <mx:Script>
        <![CDATA[
            import mx.collections. ArrayCollection;

            [Bindable] public var cTitle:String = "Services";
            [Bindable] public var ddLink2:ArrayCollec tion = new ArrayCollection( [
                {label:"Google" , url:"http:// google.com" },{label: "yahoo", url:"http:// yahoo.com" }
            ]);
            [Bindable] public var ddLink1:ArrayCollec tion = new ArrayCollection( [ 
                {label:"Hotmail" , url:"http:// hotmail.com" }
            ]);
            [Bindable] public var dpSrv:ArrayCollecti on = new ArrayCollection( [
                {Index:"45035996273 88358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
                Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
                dd:ddLink2},
                {Index:"45035996273 71609", Service:"TestBusine ssView", Priority:"Unspecifi ed", CurrentSLA:" 1",
                Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
                dd:ddLink2},
                {Index:"45035996273 71606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed", CurrentSLA:" 2",
                Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
                dd:ddLink2},
                {Index:"45035996273 7 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
                Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
                dd:ddLink1}
            ]);
        ]]>     
    </mx:Script>
    <mx:Panel id="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"
            displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );">
            <mx:dataProvider>
                <mx:GroupingCollecti on id="gc" source="{dpSrv} ">
                    <mx:grouping>
                        <mx:Grouping>
                            <mx:GroupingField name="Service" />
                        </mx:Grouping>
                    </mx:grouping>
                </mx:GroupingCollect ion>
            </mx:dataProvider>   
            <mx:columns>
                <mx:AdvancedDataGrid Column dataField="Service" headerText=" Service"/>
                <mx:AdvancedDataGrid Column dataField="Priority " headerText=" Priority" />
                <mx:AdvancedDataGrid Column id="csla" dataField="Current SLA" headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column id="hlth" dataField="Health" headerText=" Health" width="85" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column id="qlty" dataField="Quality" headerText=" Quality" width="85" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column id="rsk" dataField="Risk" headerText=" Risk" width="85" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column dataField="Avail" headerText=" Availability [24 hours]" width="85" textAlign="right" />
                <mx:AdvancedDataGrid Column dataField="OpMode" headerText=" Operational Mode" width="200" textAlign="left" />
                <mx:AdvancedDataGrid Column id="ddcol" headerText=" Drill-down" width="200" textAlign="left" />
            </mx:columns>
            <mx:rendererProvider s>  
                <mx:AdvancedDataGrid RendererProvider dataField="Current SLA" depth="2" column="{csla} " columnIndex= "2" renderer="mx. controls. Image" />
                <mx:AdvancedDataGrid RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3" renderer="mx. controls. Image" />
                <mx:AdvancedDataGrid RendererProvider dataField="Quality" depth="2" column="{qlty} " columnIndex= "4" renderer="mx. controls. Image" />
                <mx:AdvancedDataGrid RendererProvider dataField="Risk" depth="2" column="{rsk} " columnIndex= "5" renderer="mx. controls. Image" />
                <mx:AdvancedDataGrid RendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
            </mx:rendererProvide rs>
        </mx:AdvancedDataGri d>
    </mx:Panel>
</mx:Application>



PopUpMenuButtonRend erer.as:
package
{
    import flash.net.URLReques t;
    import flash.net.navigateT oURL;
    import mx.controls. PopUpMenuButton;
    import mx.events.MenuEvent ;
   
    public class PopUpMenuButtonRend erer extends PopUpMenuButton
    {
        public function PopUpMenuButtonRend erer()
        {
            super();
        }
      
        override public function set data(value:Object) :void
        {
            if(value != null)
            {  
                super.data = value;
                addEventListener( MenuEvent. ITEM_CLICK, itemClickHandler) ;
                label = "Action";
                dataProvider = value.dd;
                labelField = "label";
            }
        }
    
        public function itemClickHandler( event:MenuEvent) :void
        {                                      
            if(event && event.item.url != null)
            {
                navigateToURL( new URLRequest(event. item.url) , "_blank");
            }
        }
    }
}


HTH




Steve






Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by valdhor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why? To get the advanced datagrid stuff you need to purchase Flex Builder Pro - why not use it?

--- In flexcoders@..., Thomas Silvester <thomas_13s@...> wrote:

>
> Thanks a lot, I am not working in a Flex builder environment, i am compiling from Cmd line.
> thanks,
> Tom.
>
> --- On Thu, 11/5/09, valdhor <valdhorlists@...> wrote:
>
>
> From: valdhor <valdhorlists@...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
> To: flexcoders@...
> Date: Thursday, November 5, 2009, 8:40 PM
>
>
>  
>
>
>
> Actually, you were relatively close. If you had put a breakpoint in the set data function of the renderer, you should have seen the data you needed.
>
> Anyway, here is a cleaned up version that works as you intended:
>
> <?xml version="1.0" encoding="utf- 8"?>
> <!-- Dashboard Main Service Summary table -->
> <mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" width="100%" height="100% " backgroundColor= "#FFFFFF">
>     <mx:Style>
>         .hStyle {fontWeight: bold; fontFamily:Verdana; fontSize:12; align:center; }
>     </mx:Style>
>     <mx:Script>
>         <![CDATA[
>             import mx.collections. ArrayCollection;
>
>             [Bindable] public var cTitle:String = "Services";
>             [Bindable] public var ddLink2:ArrayCollec tion = new ArrayCollection( [
>                 {label:"Google" , url:"http:// google.com" },{label: "yahoo", url:"http:// yahoo.com" }
>             ]);
>             [Bindable] public var ddLink1:ArrayCollec tion = new ArrayCollection( [ 
>                 {label:"Hotmail" , url:"http:// hotmail.com" }
>             ]);
>             [Bindable] public var dpSrv:ArrayCollecti on = new ArrayCollection( [
>                 {Index:"45035996273 88358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>                 Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71609", Service:"TestBusine ssView", Priority:"Unspecifi ed", CurrentSLA:" 1",
>                 Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed", CurrentSLA:" 2",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 7 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink1}
>             ]);
>         ]]>     
>     </mx:Script>
>     <mx:Panel id="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"
>             displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );">
>             <mx:dataProvider>
>                 <mx:GroupingCollecti on id="gc" source="{dpSrv} ">
>                     <mx:grouping>
>                         <mx:Grouping>
>                             <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollect ion>
>             </mx:dataProvider>   
>             <mx:columns>
>                 <mx:AdvancedDataGrid Column dataField="Service" headerText=" Service"/>
>                 <mx:AdvancedDataGrid Column dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGrid Column id="csla" dataField="Current SLA" headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGrid Column id="hlth" dataField="Health" headerText=" Health" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGrid Column id="qlty" dataField="Quality" headerText=" Quality" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGrid Column id="rsk" dataField="Risk" headerText=" Risk" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGrid Column dataField="Avail" headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGrid Column dataField="OpMode" headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGrid Column id="ddcol" headerText=" Drill-down" width="200" textAlign="left" />
>             </mx:columns>
>             <mx:rendererProvider s>  
>                 <mx:AdvancedDataGrid RendererProvider dataField="Current SLA" depth="2" column="{csla} " columnIndex= "2" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGrid RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGrid RendererProvider dataField="Quality" depth="2" column="{qlty} " columnIndex= "4" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGrid RendererProvider dataField="Risk" depth="2" column="{rsk} " columnIndex= "5" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGrid RendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>             </mx:rendererProvide rs>
>         </mx:AdvancedDataGri d>
>     </mx:Panel>
> </mx:Application>
>
>
>
> PopUpMenuButtonRend erer.as:
> package
> {
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. PopUpMenuButton;
>     import mx.events.MenuEvent ;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>       
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {  
>                 super.data = value;
>                 addEventListener( MenuEvent. ITEM_CLICK, itemClickHandler) ;
>                 label = "Action";
>                 dataProvider = value.dd;
>                 labelField = "label";
>             }
>         }
>     
>         public function itemClickHandler( event:MenuEvent) :void
>         {                                      
>             if(event && event.item.url != null)
>             {
>                 navigateToURL( new URLRequest(event. item.url) , "_blank");
>             }
>         }
>     }
> }
>
>
> HTH
>
>
>
>
> Steve
>



Re: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I am new to flex and learning on the job and also under time pressure  to finish the work, now i have set up the Flex Builder Environement running my applicatiion , i am having some problem  so i was using the Cmd line to do my work.

I have another quesion Please help me out.
 
Now the same Array i have added a parentid, which has values as "0" and non-zero.
Parent id = 0 means it is the parent, parent id != 0 means that the parent of the service is that id.
 
I am setting parent id equal to the service id when parent id = 0, so the children and parent can be grouped together.
Also i need to print the tree with the parent row has values and the children under that parent as rows with values. How can I do this.
now the Array looks like below and I have added the column to the grid.
Thanks  for the help.
iam doing a check to set the Pservice
in the array dp
This will not compile just to how what I am doing.
var xp:String= (Xs[i].parentid as String);
            
          
             if(xp == "0")
             {         
            xp = xd[1];
              
              PService=xp;
            }

  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":ddArr,"PService":PService} );
         

 
<?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[
      import com.adobe.serialization.json.JSON;
      import flash.events.Event;
      import flash.events.TimerEvent;
      import flash.external.ExternalInterface;
      import flash.utils.Timer;
      import mx.collections.ArrayCollection;
      import mx.controls.AdvancedDataGrid;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
      import mx.controls.Alert;
      import mx.controls.Image;
      import mx.resources.IResourceManager;
      import mx.resources.ResourceManagerImpl;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.advancedDataGridClasses.*;
      import mx.controls.*;
      import mx.events.*;
      import mx.controls.Menu;
   
 
      [Bindable]
      public var sURL:String="";
    
      [Bindable]
      public var rURL:String = "";
     
      [Bindable]
      public var labels:ArrayCollection = null;
      [Bindable]
      public var cTitle:String = "Services";
      [Bindable]
      public var userid:String = "1";
      [Bindable]
     
      public var dObj:Object=new Object(); 
      private var myTimer:Timer;
      private var delay:uint = 30000;  // Default 30 secs
      private var repcount:uint = 0;
      private var date:Date = new Date();
      [Bindable]
      private var sDate:String = "";
          
      private function initApp( ) : void
      {
        // Do what FlexModuleFactory does, only by hand.
        var rMI:Object = flash.system.ApplicationDomain.currentDomain.getDefinition( "mx.resources.ResourceManagerImpl" );
        mx.core.Singleton.registerClass( "mx.resources.IResourceManager", Class(rMI) );     
      }
      
 
      private function onCreationComplete() : void
      {
     
        var parm:String  = Application.application.parameters.userid;
        if ( (parm != null) && (parm.length > 0) ) userid = parm;
        buildURL( );
       // Alert.show( "URL= " + sURL );
        sst.send();
    
      }
      private function buildURL( ) : void
      { 
    
    
        sURL = "charts/serviceADGTable.swf";      
      }
       private function onFaultLoad( event:FaultEvent ) : void
      {
       Alert.show("onFaultLoad: " + event.fault.message); 
      }
 
     
      private function onJSONLoad( event:ResultEvent ) : void
      {
        var rawData:String = null;
        var bObj:Object = null;
        var tObj:Object = null;
        var myMenu:Menu;
        var dp:ArrayCollection = new ArrayCollection();
        rawData = String( event.result );
        gc.source=dpSrv;  
        gc.refresh();
      
       
      }
        [Bindable]
      public var ddLink2:ArrayCollection = new ArrayCollection([
      { label1:"Google", url1:"http://google.com"},{label2:"yahoo", url2:"http://yahoo.com" }
     
            
      ]);
    [Bindable] 
   public var ddLink1:ArrayCollection = new ArrayCollection([  
     
        { label1:"Hotmail", url1:"http://hotmail.com" }
        ]);
      [Bindable]
     public var dpSrv:ArrayCollection = new ArrayCollection([
          { Index:"4503599627388358", Service:"GAUSU01-BPV-AAAA", Priority:"Unspecified", CurrentSLA:"0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production",
            dd:ddLink2, "parentid":"4503599627371867"},
          { Index:"4503599627371609", Service:"TestBusinessView", Priority:"Unspecified",  CurrentSLA:"1",
            Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production",
            dd:ddLink2 , "parentid":"4503599627371867"},
           
          { Index:"4503599627371606", Service:"Sub1BusinessView", Priority:"Unspecified",  CurrentSLA:"2",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production",
             dd:ddLink2,parentid: "0"},
          { Index:"4503599627371607", Service:"Sub2BusinessView", Priority:"Unspecified",  CurrentSLA:"3",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production",
            dd:ddLink1, "parentid":"4503599627371867"}
          ]);
  
    
    ]]>
                 
               
  </mx:Script>
 
  <mx:HTTPService id="sst" resultFormat="text" result="onJSONLoad(event)" url="{sURL}" fault="onFaultLoad(event)"/>
  <mx:Panel id="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:dataProvider>    
           
            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="PService" id="ps" width="100" visible="true" headerText="ParentService" textAlign="center" sortable="true"/>
                <!--<mx:AdvancedDataGridColumn  id="sid"  dataField="Index" headerText=""/>
 
                <mx:AdvancedDataGridColumn dataField="Service" headerText="Service" width="100" textAlign="center" sortable="true"/>-->                                                  
                <mx:AdvancedDataGridColumn  dataField="Priority" headerText="Priority" width="65" textAlign="center" sortable="true"/>
                <mx:AdvancedDataGridColumn  id ="csla" dataField="Current SLA"  headerText="Current SLA" width="16" textAlign="center" sortable="true"/>
                <mx:AdvancedDataGridColumn id="hlth" dataField="Health"  headerText="Health" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"  headerText="Quality" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"  headerText="Risk" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn dataField="Avail"  headerText="Availability [24 hours]" width="45" textAlign="right"/>
                <mx:AdvancedDataGridColumn dataField="OpMode"  headerText="Operational Mode" width="65" textAlign="left"/>
                <mx:AdvancedDataGridColumn id ="ddcol" headerText="Launch To" width="200" textAlign="left"> <!--itemRenderer="mx.controls.PopUpButton"-->
                   
         </mx:AdvancedDataGridColumn>   
               </mx:columns>
             <mx:rendererProviders>  
            <!--  <mx:AdvancedDataGridRendererProvider dataField="Index" depth="2"  column="{sid}" columnIndex="0"
               renderer="com.ca.RadioButtonRenderer"/>-->
              <mx:AdvancedDataGridRendererProvider dataField="Current SLA" depth="2"  column="{csla}" columnIndex="2"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Health" depth="2" column="{hlth}" columnIndex="3"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Quality" depth="2"  column="{qlty}" columnIndex="4"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Risk" depth="2"  column="{rsk}" columnIndex="5"
             renderer="mx.controls.Image" /> 
             <mx:AdvancedDataGridRendererProvider dataField="dd" column="{ddcol} " depth="2"   columnIndex="8" renderer="com.ca.PopUpMenuButtonRenderer" />
             </mx:rendererProviders> 
          
       </mx:AdvancedDataGrid>
  
  </mx:Panel>
</mx:Application>

 
 
 
 

 
--- On Thu, 11/5/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Thursday, November 5, 2009, 9:12 PM


 



Why? To get the advanced datagrid stuff you need to purchase Flex Builder Pro - why not use it?

--- In flexcoders@yahoogro ups.com, Thomas Silvester <thomas_13s@ ...> wrote:

>
> Thanks a lot, I am not working in a Flex builder environment, i am compiling from Cmd line.
> thanks,
> Tom.
>
> --- On Thu, 11/5/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
> To: flexcoders@yahoogro ups.com
> Date: Thursday, November 5, 2009, 8:40 PM
>
>
>  
>
>
>
> Actually, you were relatively close. If you had put a breakpoint in the set data function of the renderer, you should have seen the data you needed.
>
> Anyway, here is a cleaned up version that works as you intended:
>
> <?xml version="1.0" encoding="utf- 8"?>
> <!-- Dashboard Main Service Summary table -->
> <mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" width="100%" height="100% " backgroundColor= "#FFFFFF">
>     <mx:Style>
>         .hStyle {fontWeight: bold; fontFamily:Verdana; fontSize:12; align:center; }
>     </mx:Style>
>     <mx:Script>
>         <![CDATA[
>             import mx.collections. ArrayCollection;
>
>             [Bindable] public var cTitle:String = "Services";
>             [Bindable] public var ddLink2:ArrayCollec tion = new ArrayCollection( [
>                 {label:"Google" , url:"http:// google.com" },{label: "yahoo", url:"http:// yahoo.com" }
>             ]);
>             [Bindable] public var ddLink1:ArrayCollec tion = new ArrayCollection( [ 
>                 {label:"Hotmail" , url:"http:// hotmail.com" }
>             ]);
>             [Bindable] public var dpSrv:ArrayCollecti on = new ArrayCollection( [
>                 {Index:"45035996273 88358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>                 Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71609", Service:"TestBusine ssView", Priority:"Unspecifi ed", CurrentSLA:" 1",
>                 Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed", CurrentSLA:" 2",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 7 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink1}
>             ]);
>         ]]>     
>     </mx:Script>
>     <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% " titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF]" >
>         <mx:AdvancedDataGri d id="srvTable" width="100%" height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
>             enabled="true" showHeaders= "true"
>             displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );">
>             <mx:dataProvider>
>                 <mx:GroupingCollect i on id="gc" source="{dpSrv} ">
>                     <mx:grouping>
>                         <mx:Grouping>
>                             <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollec t ion>
>             </mx:dataProvider>   
>             <mx:columns>
>                 <mx:AdvancedDataGri d Column dataField="Service" headerText=" Service"/>
>                 <mx:AdvancedDataGri d Column dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGri d Column id="csla" dataField="Current SLA" headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="hlth" dataField="Health" headerText=" Health" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="qlty" dataField="Quality" headerText=" Quality" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="rsk" dataField="Risk" headerText=" Risk" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column dataField="Avail" headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGri d Column dataField="OpMode" headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGri d Column id="ddcol" headerText=" Drill-down" width="200" textAlign="left" />
>             </mx:columns>
>             <mx:rendererProvide r s>  
>                 <mx:AdvancedDataGri d RendererProvider dataField="Current SLA" depth="2" column="{csla} " columnIndex= "2" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Quality" depth="2" column="{qlty} " columnIndex= "4" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Risk" depth="2" column="{rsk} " columnIndex= "5" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>             </mx:rendererProvid e rs>
>         </mx:AdvancedDataGr i d>
>     </mx:Panel>
> </mx:Application>
>
>
>
> PopUpMenuButtonRend erer.as:
> package
> {
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. PopUpMenuButton;
>     import mx.events.MenuEvent ;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>       
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {  
>                 super.data = value;
>                 addEventListener( MenuEvent. ITEM_CLICK, itemClickHandler) ;
>                 label = "Action";
>                 dataProvider = value.dd;
>                 labelField = "label";
>             }
>         }
>     
>         public function itemClickHandler( event:MenuEvent) :void
>         {                                      
>             if(event && event.item.url != null)
>             {
>                 navigateToURL( new URLRequest(event. item.url) , "_blank");
>             }
>         }
>     }
> }
>
>
> HTH
>
>
>
>
> Steve
>







RE: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Tracy Spratt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Instead of {"Index":xd[0], …}

do: {Index:xd[0], …}; //leave off the quotes

 

Other than that, what line is the compile error?

 

Also that is not an “Array”,  it is an “Object” or “hashtable”, or
“associative array”

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: flexcoders@... [mailto:flexcoders@...] On
Behalf Of Thomas Silvester
Sent: Saturday, November 07, 2009 9:49 AM
To: flexcoders@...
Subject: Re: [flexcoders] Re: How can I put a PopUPMenuButton in an
AdvancedDatagridColumn?

 

 


Hi,

I am new to flex and learning on the job and also under time pressure  to
finish the work, now i have set up the Flex Builder Environement running my
applicatiion , i am having some problem  so i was using the Cmd line to do
my work.

I have another quesion Please help me out.

 

Now the same Array i have added a parentid, which has values as "0" and
non-zero.

Parent id = 0 means it is the parent, parent id != 0 means that the parent
of the service is that id.

 

I am setting parent id equal to the service id when parent id = 0, so the
children and parent can be grouped together.

Also i need to print the tree with the parent row has values and the
children under that parent as rows with values. How can I do this.

now the Array looks like below and I have added the column to the grid.

Thanks  for the help.

iam doing a check to set the Pservice

in the array dp

This will not compile just to how what I am doing.

var xp:String= (Xs[i].parentid as String);
             
           
             if(xp == "0")
             {        
            xp = xd[1];
             
              PService=xp;
            }

  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":ddArr,"PService":PService} );
         

 

<?xml version="1.0"?>
<!-- Dashboard Main Service Summary table -->
<mx:Application xmlns:mx="http://www.adobe. <http://www.adobe.com/2006/mxml>
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[
      import com.adobe.serialization.json.JSON;
      import flash.events.Event;
      import flash.events.TimerEvent;
      import flash.external.ExternalInterface;
      import flash.utils.Timer;
      import mx.collections.ArrayCollection;
      import mx.controls.AdvancedDataGrid;
      import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
      import mx.controls.Alert;
      import mx.controls.Image;
      import mx.resources.IResourceManager;
      import mx.resources.ResourceManagerImpl;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.events.FaultEvent;
      import mx.controls.advancedDataGridClasses.*;
      import mx.controls.*;
      import mx.events.*;
      import mx.controls.Menu;
   
 

      [Bindable]
      public var sURL:String="";
     
      [Bindable]
      public var rURL:String = "";
     
      [Bindable]
      public var labels:ArrayCollection = null;

      [Bindable]
      public var cTitle:String = "Services";

      [Bindable]
      public var userid:String = "1";
      [Bindable]
     
      public var dObj:Object=new Object();  
      private var myTimer:Timer;
      private var delay:uint = 30000;  // Default 30 secs
      private var repcount:uint = 0;
      private var date:Date = new Date();

      [Bindable]
      private var sDate:String = "";
           
      private function initApp( ) : void
      {
        // Do what FlexModuleFactory does, only by hand.
        var rMI:Object =
flash.system.ApplicationDomain.currentDomain.getDefinition(
"mx.resources.ResourceManagerImpl" );
        mx.core.Singleton.registerClass( "mx.resources.IResourceManager",
Class(rMI) );      
      }
       
 
      private function onCreationComplete() : void
      {
     
        var parm:String  = Application.application.parameters.userid;
        if ( (parm != null) && (parm.length > 0) ) userid = parm;

        buildURL( );
       // Alert.show( "URL= " + sURL );
        sst.send();
     
      }
      private function buildURL( ) : void
      {  
     
     
        sURL = "charts/serviceADGTable.swf";      
      }

       private function onFaultLoad( event:FaultEvent ) : void
      {
       Alert.show("onFaultLoad: " + event.fault.message);  
      }
 
     
      private function onJSONLoad( event:ResultEvent ) : void
      {
        var rawData:String = null;
        var bObj:Object = null;
        var tObj:Object = null;
        var myMenu:Menu;
        var dp:ArrayCollection = new ArrayCollection();
        rawData = String( event.result );
        gc.source=dpSrv;  
        gc.refresh();
       
       
      }

        [Bindable]
      public var ddLink2:ArrayCollection = new ArrayCollection([
      { label1:"Google", url1:"http://google. <http://google.com>
com"},{label2:"yahoo", url2:"http://yahoo. <http://yahoo.com> com" }
     
             
      ]);
    [Bindable]  
   public var ddLink1:ArrayCollection = new ArrayCollection([  
     
        { label1:"Hotmail", url1:"http://hotmail. <http://hotmail.com> com"
}

        ]);
      [Bindable]
     public var dpSrv:ArrayCollection = new ArrayCollection([
          { Index:"4503599627388358", Service:"GAUSU01-BPV-AAAA",
Priority:"Unspecified", CurrentSLA:"0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%",
OpMode:"Production",
            dd:ddLink2, "parentid":"4503599627371867"},

          { Index:"4503599627371609", Service:"TestBusinessView",
Priority:"Unspecified",  CurrentSLA:"1",

            Health:"2", Quality:"0", Risk:"2", Avail:"0%",
OpMode:"Production",
            dd:ddLink2 , "parentid":"4503599627371867"},
           
          { Index:"4503599627371606", Service:"Sub1BusinessView",
Priority:"Unspecified",  CurrentSLA:"2",

            Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production",
             dd:ddLink2,parentid: "0"},

          { Index:"4503599627371607", Service:"Sub2BusinessView",
Priority:"Unspecified",  CurrentSLA:"3",

            Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production",
            dd:ddLink1, "parentid":"4503599627371867"}

          ]);
   
     
    ]]>
                 
               
  </mx:Script>

 

  <mx:HTTPService id="sst" resultFormat="text" result="onJSONLoad(event)"
url="{sURL}" fault="onFaultLoad(event)"/>

  <mx:Panel id="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:dataProvider>    
           
            <mx:columns>
                <mx:AdvancedDataGridColumn dataField="PService" id="ps"
width="100" visible="true" headerText="ParentService" textAlign="center"
sortable="true"/>
                <!--<mx:AdvancedDataGridColumn  id="sid"  dataField="Index"
headerText=""/>
 
                <mx:AdvancedDataGridColumn dataField="Service"
headerText="Service" width="100" textAlign="center" sortable="true"/>-->

                <mx:AdvancedDataGridColumn  dataField="Priority"
headerText="Priority" width="65" textAlign="center" sortable="true"/>
                <mx:AdvancedDataGridColumn  id ="csla" dataField="Current
SLA"  headerText="Current SLA" width="16" textAlign="center"
sortable="true"/>
                <mx:AdvancedDataGridColumn id="hlth" dataField="Health"
headerText="Health" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="qlty" dataField="Quality"
headerText="Quality" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn id="rsk" dataField="Risk"
headerText="Risk" width="45" textAlign="center"  sortable="true"/>
                <mx:AdvancedDataGridColumn dataField="Avail"
headerText="Availability [24 hours]" width="45" textAlign="right"/>
                <mx:AdvancedDataGridColumn dataField="OpMode"
headerText="Operational Mode" width="65" textAlign="left"/>
                <mx:AdvancedDataGridColumn id ="ddcol" headerText="Launch
To" width="200" textAlign="left">
<!--itemRenderer="mx.controls.PopUpButton"-->
                   
         </mx:AdvancedDataGridColumn>    
               </mx:columns>
             <mx:rendererProviders>  
            <!--  <mx:AdvancedDataGridRendererProvider dataField="Index"
depth="2"  column="{sid}" columnIndex="0"
               renderer="com.ca.RadioButtonRenderer"/>-->
              <mx:AdvancedDataGridRendererProvider dataField="Current SLA"
depth="2"  column="{csla}" columnIndex="2"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Health"
depth="2" column="{hlth}" columnIndex="3"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Quality"
depth="2"  column="{qlty}" columnIndex="4"
             renderer="mx.controls.Image" />
             <mx:AdvancedDataGridRendererProvider dataField="Risk" depth="2"
column="{rsk}" columnIndex="5"
             renderer="mx.controls.Image" />  
             <mx:AdvancedDataGridRendererProvider dataField="dd"
column="{ddcol} " depth="2"   columnIndex="8"
renderer="com.ca.PopUpMenuButtonRenderer" />
             </mx:rendererProviders>  
           
       </mx:AdvancedDataGrid>

   
  </mx:Panel>

</mx:Application>

 

 

 

 

 
--- On Thu, 11/5/09, valdhor <valdhorlists@...> wrote:


From: valdhor <valdhorlists@...>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an
AdvancedDatagridColumn?
To: flexcoders@...
Date: Thursday, November 5, 2009, 9:12 PM

 

Why? To get the advanced datagrid stuff you need to purchase Flex Builder
Pro - why not use it?

--- In flexcoders@yahoogro
<http://us.mc504.mail.yahoo.com/mc/compose?to=flexcoders%40yahoogroups.com>
ups.com, Thomas Silvester <thomas_13s@ ...> wrote:
>
> Thanks a lot, I am not working in a Flex builder environment, i am
compiling from Cmd line.
> thanks,
> Tom.
>
> --- On Thu, 11/5/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an
AdvancedDatagridCol umn?
> To: flexcoders@yahoogro
<http://us.mc504.mail.yahoo.com/mc/compose?to=flexcoders%40yahoogroups.com>
ups.com
> Date: Thursday, November 5, 2009, 8:40 PM
>
>
> Â  
>
>
>
> Actually, you were relatively close. If you had put a breakpoint in the
set data function of the renderer, you should have seen the data you needed.

>
> Anyway, here is a cleaned up version that works as you intended:
>
> <?xml version="1.0" encoding="utf- 8"?>
> <!-- Dashboard Main Service Summary table -->
> <mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" width="100%"
height="100% " backgroundColor= "#FFFFFF">
> Â Â Â  <mx:Style>
> Â Â Â  Â Â Â  .hStyle {fontWeight: bold; fontFamily:Verdana; fontSize:12;
align:center; }
> Â Â Â  </mx:Style>
> Â Â Â  <mx:Script>
> Â Â Â  Â Â Â  <![CDATA[
> Â Â Â  Â Â Â  Â Â Â  import mx.collections. ArrayCollection;
>
> Â Â Â  Â Â Â  Â Â Â  [Bindable] public var cTitle:String = "Services";
> Â Â Â  Â Â Â  Â Â Â  [Bindable] public var ddLink2:ArrayCollec tion = new
ArrayCollection( [
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {label:"Google" , url:"http:// google.com"
},{label: "yahoo", url:"http:// yahoo.com" }
> Â Â Â  Â Â Â  Â Â Â  ]);
> Â Â Â  Â Â Â  Â Â Â  [Bindable] public var ddLink1:ArrayCollec tion = new
ArrayCollection( [Â  
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {label:"Hotmail" , url:"http:// hotmail.com" }
> Â Â Â  Â Â Â  Â Â Â  ]);
> Â Â Â  Â Â Â  Â Â Â  [Bindable] public var dpSrv:ArrayCollecti on = new
ArrayCollection( [
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {Index:"45035996273 88358", Service:"GAUSU01-
BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Health:"3", Quality:"0", Risk:"3", Avail:"0%",
OpMode:"Production" ,
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  dd:ddLink2},
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {Index:"45035996273 71609",
Service:"TestBusine ssView", Priority:"Unspecifi ed", CurrentSLA:" 1",
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Health:"2", Quality:"0", Risk:"2", Avail:"0%",
OpMode:"Production" ,
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  dd:ddLink2},
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {Index:"45035996273 71606",
Service:"Sub1Busine ssView", Priority:"Unspecifi ed", CurrentSLA:" 2",
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production" ,
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  dd:ddLink2},
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  {Index:"45035996273 7 1607",
Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Health:"0", Quality:"0", Risk:"0", Avail:"0%",
OpMode:"Production" ,
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  dd:ddLink1}
> Â Â Â  Â Â Â  Â Â Â  ]);
> Â Â Â  Â Â Â  ]]>Â Â Â Â Â  
> Â Â Â  </mx:Script>
> Â Â Â  <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% "
titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF]" >
> Â Â Â  Â Â Â  <mx:AdvancedDataGri d id="srvTable" width="100%"
height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
> Â Â Â  Â Â Â  Â Â Â  enabled="true" showHeaders= "true"
> Â Â Â  Â Â Â  Â Â Â  displayItemsExpande d="true" variableRowHeight=
"true" wordWrap="false" initialize=" gc.refresh( );">
> Â Â Â  Â Â Â  Â Â Â  <mx:dataProvider>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:GroupingCollect i on id="gc"
source="{dpSrv} ">
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:grouping>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:Grouping>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:GroupingField
name="Service" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  </mx:Grouping>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  Â Â Â  </mx:grouping>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  </mx:GroupingCollec t ion>
> Â Â Â  Â Â Â  Â Â Â  </mx:dataProvider>Â Â Â  
> Â Â Â  Â Â Â  Â Â Â  <mx:columns>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column
dataField="Service" headerText=" Service"/>
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column
dataField="Priority " headerText=" Priority" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column id="csla"
dataField="Current SLA" headerText=" Current SLA" width="85"
textAlign="center" sortable="true" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column id="hlth"
dataField="Health" headerText=" Health" width="85" textAlign="center"
sortable="true" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column id="qlty"
dataField="Quality" headerText=" Quality" width="85" textAlign="center"
sortable="true" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column id="rsk"
dataField="Risk" headerText=" Risk" width="85" textAlign="center"
sortable="true" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column dataField="Avail"
headerText=" Availability [24 hours]" width="85" textAlign="right" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column
dataField="OpMode" headerText=" Operational Mode" width="200"
textAlign="left" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d Column id="ddcol"
headerText=" Drill-down" width="200" textAlign="left" />
> Â Â Â  Â Â Â  Â Â Â  </mx:columns>
> Â Â Â  Â Â Â  Â Â Â  <mx:rendererProvide r s>Â Â  
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d RendererProvider
dataField="Current SLA" depth="2" column="{csla} " columnIndex= "2"
renderer="mx. controls. Image" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d RendererProvider
dataField="Health" depth="2" column="{hlth} " columnIndex= "3" renderer="mx.
controls. Image" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d RendererProvider
dataField="Quality" depth="2" column="{qlty} " columnIndex= "4"
renderer="mx. controls. Image" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d RendererProvider
dataField="Risk" depth="2" column="{rsk} " columnIndex= "5" renderer="mx.
controls. Image" />
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  <mx:AdvancedDataGri d RendererProvider
dataField="dd" column="{ddcol} " depth="2" renderer="PopUpMenu
ButtonRenderer" />

> Â Â Â  Â Â Â  Â Â Â  </mx:rendererProvid e rs>
> Â Â Â  Â Â Â  </mx:AdvancedDataGr i d>
> Â Â Â  </mx:Panel>
> </mx:Application>
>
>
>
> PopUpMenuButtonRend erer.as:
> package
> {
> Â Â Â  import flash.net.URLReques t;
> Â Â Â  import flash.net.navigateT oURL;
> Â Â Â  import mx.controls. PopUpMenuButton;
> Â Â Â  import mx.events.MenuEvent ;
> Â Â Â  
> Â Â Â  public class PopUpMenuButtonRend erer extends PopUpMenuButton
> Â Â Â  {
> Â Â Â  Â Â Â  public function PopUpMenuButtonRend erer()
> Â Â Â  Â Â Â  {
> Â Â Â  Â Â Â  Â Â Â  super();
> Â Â Â  Â Â Â  }
> Â Â Â Â Â Â  
> Â Â Â  Â Â Â  override public function set data(value:Object) :void
> Â Â Â  Â Â Â  {
> Â Â Â  Â Â Â  Â Â Â  if(value != null)
> Â Â Â  Â Â Â  Â Â Â  {Â Â  
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  super.data = value;
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  addEventListener( MenuEvent. ITEM_CLICK,
itemClickHandler) ;
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  label = "Action";
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  dataProvider = value.dd;
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  labelField = "label";
> Â Â Â  Â Â Â  Â Â Â  }
> Â Â Â  Â Â Â  }
> Â Â Â Â  
> Â Â Â  Â Â Â  public function itemClickHandler( event:MenuEvent) :void
> Â Â Â  Â Â Â  {Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
         
> Â Â Â  Â Â Â  Â Â Â  if(event && event.item.url != null)
> Â Â Â  Â Â Â  Â Â Â  {
> Â Â Â  Â Â Â  Â Â Â  Â Â Â  navigateToURL( new URLRequest(event. item.url)
, "_blank");

> Â Â Â  Â Â Â  Â Â Â  }
> Â Â Â  Â Â Â  }
> Â Â Â  }
> }
>
>
> HTH
>
>
>
>
> Steve
>




RE: Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?

by Thomas Silvester :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,
When i do the below code what  I see is the parent servicename  as one row in the tree and as a child again the parent service and its data as another row  and some where down the tree the child as  another row with only service name in the first row and as a child the  servicename and its other coulumns, i would like to get the Parent service as a row with its other column DATA AS A ROW and then the child immediately under that when I open the parent  with all its data as a row in a tree structrure, how can i ge thtis type of grouping from   the  below array dpSrv.  Please forget about the array dp.
 If you copy the mxml code and the Action Script below in my last reply it will compile for you.
thanks,
Tom.
--- On Sun, 11/8/09, Tracy Spratt <tracy@...> wrote:


From: Tracy Spratt <tracy@...>
Subject: RE: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridColumn?
To: flexcoders@...
Date: Sunday, November 8, 2009, 9:51 PM


 





Instead of {"Index":xd[0] , …}

do: {Index:xd[0] , …}; //leave off the quotes
 
Other than that, what line is the compile error?
 
Also that is not an “Array”,  it is an “Object” or “hashtable”, or “associative array”
 
Tracy Spratt,
Lariat Services, development services available




From: flexcoders@yahoogro ups.com [mailto:flexcoders@ yahoogroups. com] On Behalf Of Thomas Silvester
Sent: Saturday, November 07, 2009 9:49 AM
To: flexcoders@yahoogro ups.com
Subject: Re: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
 
 








Hi,

I am new to flex and learning on the job and also under time pressure  to finish the work, now i have set up the Flex Builder Environement running my applicatiion , i am having some problem  so i was using the Cmd line to do my work.

I have another quesion Please help me out.

 

Now the same Array i have added a parentid, which has values as "0" and non-zero.
Parent id = 0 means it is the parent, parent id != 0 means that the parent of the service is that id.
 
I am setting parent id equal to the service id when parent id = 0, so the children and parent can be grouped together.
Also i need to print the tree with the parent row has values and the children under that parent as rows with values. How can I do this.
now the Array looks like below and I have added the column to the grid.
Thanks  for the help.
iam doing a check to set the Pservice
in the array dp
This will not compile just to how what I am doing.
var xp:String= (Xs[i].parentid as String);
            
          
             if(xp == "0")
             {         
            xp = xd[1];
              
              PService=xp;
            }
  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":ddArr," PService" :PService} );
         
 
<?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= "onCreationCompl ete();">
  <mx:Style>
    .hStyle { fontWeight:bold; fontFamily:Verdana; fontSize:12; align:center; }
  </mx:Style>
  <mx:Script>
    <![CDATA[
      import com.adobe.serializa tion.json. JSON;
      import flash.events. Event;
      import flash.events. TimerEvent;
      import flash.external. ExternalInterfac e;
      import flash.utils. Timer;
      import mx.collections. ArrayCollection;
      import mx.controls. AdvancedDataGrid ;
      import mx.controls. advancedDataGrid Classes.Advanced DataGridColumn;
      import mx.controls. Alert;
      import mx.controls. Image;
      import mx.resources. IResourceManager ;
      import mx.resources. ResourceManagerI mpl;
      import mx.rpc.events. ResultEvent;
      import mx.rpc.events. FaultEvent;
      import mx.controls. advancedDataGrid Classes.* ;
      import mx.controls. *;
      import mx.events.*;
      import mx.controls. Menu;
   
 
      [Bindable]
      public var sURL:String= "";
    
      [Bindable]
      public var rURL:String = "";
     
      [Bindable]
      public var labels:ArrayCollect ion = null;
      [Bindable]
      public var cTitle:String = "Services";
      [Bindable]
      public var userid:String = "1";
      [Bindable]
     
      public var dObj:Object= new Object(); 
      private var myTimer:Timer;
      private var delay:uint = 30000;  // Default 30 secs
      private var repcount:uint = 0;
      private var date:Date = new Date();
      [Bindable]
      private var sDate:String = "";
          
      private function initApp( ) : void
      {
        // Do what FlexModuleFactory does, only by hand.
        var rMI:Object = flash.system. ApplicationDomai n.currentDomain. getDefinition( "mx.resources. ResourceManagerI mpl" );
        mx.core.Singleton. registerClass( "mx.resources. IResourceManager ", Class(rMI) );     
      }
      
 
      private function onCreationComplete( ) : void
      {
     
        var parm:String  = Application. application. parameters. userid;
        if ( (parm != null) && (parm.length > 0) ) userid = parm;
        buildURL( );
       // Alert.show( "URL= " + sURL );
        sst.send();
    
      }
      private function buildURL( ) : void
      { 
    
    
        sURL = "charts/serviceADGT able.swf" ;      
      }
       private function onFaultLoad( event:FaultEvent ) : void
      {
       Alert.show(" onFaultLoad: " + event.fault. message); 
      }
 
     
      private function onJSONLoad( event:ResultEvent ) : void
      {
        var rawData:String = null;
        var bObj:Object = null;
        var tObj:Object = null;
        var myMenu:Menu;
        var dp:ArrayCollection = new ArrayCollection( );
        rawData = String( event.result );
        gc.source=dpSrv;  
        gc.refresh() ;
      
       
      }
        [Bindable]
      public var ddLink2:ArrayCollec tion = new ArrayCollection( [
      { label1:"Google" , url1:"http://google. com"},{label2: "yahoo", url2:"http://yahoo. com" }
     
            
      ]);
    [Bindable] 
   public var ddLink1:ArrayCollec tion = new ArrayCollection( [  
     
        { label1:"Hotmail" , url1:"http://hotmail. com" }
        ]);
      [Bindable]
     public var dpSrv:ArrayCollecti on = new ArrayCollection( [
          { Index:"450359962738 8358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
            Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
            dd:ddLink2, "parentid":" 4503599627371867 "},
          { Index:"450359962737 1609", Service:"TestBusine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 1",
            Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
            dd:ddLink2 , "parentid":" 4503599627371867 "},
           
          { Index:"450359962737 1606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 2",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
             dd:ddLink2,parentid : "0"},
          { Index:"450359962737 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
            Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
            dd:ddLink1, "parentid":" 4503599627371867 "}
          ]);
  
    
    ]]>
                 
               
  </mx:Script>
 
  <mx:HTTPService id="sst" resultFormat= "text" result="onJSONLoad( event)" url="{sURL}" fault="onFaultLoad( event)"/>
  <mx:Panel id="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"
displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );"  > 
      
            <mx:dataProvider>
               <mx:GroupingCollecti on id="gc" source ="{dpSrv}">
                    <mx:grouping>
                        <mx:Grouping>
                          <mx:GroupingField name="PService" />
                         <!--<mx:GroupingField name="Service" />-->
                        </mx:Grouping>
                    </mx:grouping>
                </mx:GroupingCollect ion> 
             
                </mx:dataProvider>    
           
            <mx:columns>
                <mx:AdvancedDataGrid Column dataField="PService " id="ps" width="100" visible="true" headerText=" ParentService" textAlign="center" sortable="true" />
                <!--<mx:AdvancedDataGrid Column  id="sid"  dataField="Index" headerText=" "/>
 
                <mx:AdvancedDataGrid Column dataField="Service" headerText=" Service" width="100" textAlign="center" sortable="true" />-->                                                  
                <mx:AdvancedDataGrid Column  dataField="Priority " headerText=" Priority" width="65" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column  id ="csla" dataField="Current SLA"  headerText=" Current SLA" width="16" textAlign="center" sortable="true" />
                <mx:AdvancedDataGrid Column id="hlth" dataField="Health"  headerText=" Health" width="45" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column id="qlty" dataField="Quality"  headerText=" Quality" width="45" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column id="rsk" dataField="Risk"  headerText=" Risk" width="45" textAlign="center"  sortable="true" />
                <mx:AdvancedDataGrid Column dataField="Avail"  headerText=" Availability [24 hours]" width="45" textAlign="right" />
                <mx:AdvancedDataGrid Column dataField="OpMode"  headerText=" Operational Mode" width="65" textAlign="left" />
                <mx:AdvancedDataGrid Column id ="ddcol" headerText=" Launch To" width="200" textAlign="left"> <!--itemRenderer= "mx.controls. PopUpButton" -->
                   
         </mx:AdvancedDataGri dColumn>   
               </mx:columns>
             <mx:rendererProvider s>  
            <!--  <mx:AdvancedDataGrid RendererProvider dataField="Index" depth="2"  column="{sid} " columnIndex= "0"
               renderer="com. ca.RadioButtonRe nderer"/>-->
              <mx:AdvancedDataGrid RendererProvider dataField="Current SLA" depth="2"  column="{csla} " columnIndex= "2"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Quality" depth="2"  column="{qlty} " columnIndex= "4"
             renderer="mx. controls. Image" />
             <mx:AdvancedDataGrid RendererProvider dataField="Risk" depth="2"  column="{rsk} " columnIndex= "5"
             renderer="mx. controls. Image" /> 
             <mx:AdvancedDataGrid RendererProvider dataField="dd" column="{ddcol} " depth="2"   columnIndex= "8" renderer="com. ca.PopUpMenuButt onRenderer" />
             </mx:rendererProvide rs> 
          
       </mx:AdvancedDataGri d>
  
  </mx:Panel>
</mx:Application>
 
 
 
 


 
--- On Thu, 11/5/09, valdhor <valdhorlists@ embarqmail. com> wrote:


From: valdhor <valdhorlists@ embarqmail. com>
Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
To: flexcoders@yahoogro ups.com
Date: Thursday, November 5, 2009, 9:12 PM

 


Why? To get the advanced datagrid stuff you need to purchase Flex Builder Pro - why not use it?

--- In flexcoders@yahoogro ups.com, Thomas Silvester <thomas_13s@ ...> wrote:

>
> Thanks a lot, I am not working in a Flex builder environment, i am compiling from Cmd line.
> thanks,
> Tom.
>
> --- On Thu, 11/5/09, valdhor <valdhorlists@ ...> wrote:
>
>
> From: valdhor <valdhorlists@ ...>
> Subject: [flexcoders] Re: How can I put a PopUPMenuButton in an AdvancedDatagridCol umn?
> To: flexcoders@yahoogro ups.com
> Date: Thursday, November 5, 2009, 8:40 PM
>
>
>  
>
>
>
> Actually, you were relatively close. If you had put a breakpoint in the set data function of the renderer, you should have seen the data you needed.
>
> Anyway, here is a cleaned up version that works as you intended:
>
> <?xml version="1.0" encoding="utf- 8"?>
> <!-- Dashboard Main Service Summary table -->
> <mx:Application xmlns:mx="http: //www.adobe. com/2006/ mxml" width="100%" height="100% " backgroundColor= "#FFFFFF">
>     <mx:Style>
>         .hStyle {fontWeight: bold; fontFamily:Verdana; fontSize:12; align:center; }
>     </mx:Style>
>     <mx:Script>
>         <![CDATA[
>             import mx.collections. ArrayCollection;
>
>             [Bindable] public var cTitle:String = "Services";
>             [Bindable] public var ddLink2:ArrayCollec tion = new ArrayCollection( [
>                 {label:"Google" , url:"http:// google.com" },{label: "yahoo", url:"http:// yahoo.com" }
>             ]);
>             [Bindable] public var ddLink1:ArrayCollec tion = new ArrayCollection( [ 
>                 {label:"Hotmail" , url:"http:// hotmail.com" }
>             ]);
>             [Bindable] public var dpSrv:ArrayCollecti on = new ArrayCollection( [
>                 {Index:"45035996273 88358", Service:"GAUSU01- BPV-AAAA" , Priority:"Unspecifi ed", CurrentSLA:" 0",
>                 Health:"3", Quality:"0", Risk:"3", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71609", Service:"TestBusine ssView", Priority:"Unspecifi ed", CurrentSLA:" 1",
>                 Health:"2", Quality:"0", Risk:"2", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 71606", Service:"Sub1Busine ssView", Priority:"Unspecifi ed", CurrentSLA:" 2",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink2},
>                 {Index:"45035996273 7 1607", Service:"Sub2Busine ssView", Priority:"Unspecifi ed",  CurrentSLA:" 3",
>                 Health:"0", Quality:"0", Risk:"0", Avail:"0%", OpMode:"Production" ,
>                 dd:ddLink1}
>             ]);
>         ]]>     
>     </mx:Script>
>     <mx:Panel id="panel" title="{cTitle} " width="100%" height="100% " titleStyleName= "hStyle" headerColors= "[0xC5DFF9, 0xEFF6FF]" >
>         <mx:AdvancedDataGri d id="srvTable" width="100%" height="100% " color="0x323232" dragEnabled= "true" dropEnabled= "true"
>             enabled="true" showHeaders= "true"
>             displayItemsExpande d="true" variableRowHeight= "true" wordWrap="false" initialize=" gc.refresh( );">
>             <mx:dataProvider>
>                 <mx:GroupingCollect i on id="gc" source="{dpSrv} ">
>                     <mx:grouping>
>                         <mx:Grouping>
>                             <mx:GroupingField name="Service" />
>                         </mx:Grouping>
>                     </mx:grouping>
>                 </mx:GroupingCollec t ion>
>             </mx:dataProvider>   
>             <mx:columns>
>                 <mx:AdvancedDataGri d Column dataField="Service" headerText=" Service"/>
>                 <mx:AdvancedDataGri d Column dataField="Priority " headerText=" Priority" />
>                 <mx:AdvancedDataGri d Column id="csla" dataField="Current SLA" headerText=" Current SLA" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="hlth" dataField="Health" headerText=" Health" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="qlty" dataField="Quality" headerText=" Quality" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column id="rsk" dataField="Risk" headerText=" Risk" width="85" textAlign="center" sortable="true" />
>                 <mx:AdvancedDataGri d Column dataField="Avail" headerText=" Availability [24 hours]" width="85" textAlign="right" />
>                 <mx:AdvancedDataGri d Column dataField="OpMode" headerText=" Operational Mode" width="200" textAlign="left" />
>                 <mx:AdvancedDataGri d Column id="ddcol" headerText=" Drill-down" width="200" textAlign="left" />
>             </mx:columns>
>             <mx:rendererProvide r s>  
>                 <mx:AdvancedDataGri d RendererProvider dataField="Current SLA" depth="2" column="{csla} " columnIndex= "2" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Health" depth="2" column="{hlth} " columnIndex= "3" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Quality" depth="2" column="{qlty} " columnIndex= "4" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="Risk" depth="2" column="{rsk} " columnIndex= "5" renderer="mx. controls. Image" />
>                 <mx:AdvancedDataGri d RendererProvider dataField="dd" column="{ddcol} " depth="2" renderer="PopUpMenu ButtonRenderer" />
>             </mx:rendererProvid e rs>
>         </mx:AdvancedDataGr i d>
>     </mx:Panel>
> </mx:Application>
>
>
>
> PopUpMenuButtonRend erer.as:
> package
> {
>     import flash.net.URLReques t;
>     import flash.net.navigateT oURL;
>     import mx.controls. PopUpMenuButton;
>     import mx.events.MenuEvent ;
>    
>     public class PopUpMenuButtonRend erer extends PopUpMenuButton
>     {
>         public function PopUpMenuButtonRend erer()
>         {
>             super();
>         }
>       
>         override public function set data(value:Object) :void
>         {
>             if(value != null)
>             {  
>                 super.data = value;
>                 addEventListener( MenuEvent. ITEM_CLICK, itemClickHandler) ;
>                 label = "Action";
>                 dataProvider = value.dd;
>                 labelField = "label";
>             }
>         }
>     
>         public function itemClickHandler( event:MenuEvent) :void
>         {                                      
>             if(event && event.item.url != null)
>             {
>                 navigateToURL( new URLRequest(event. item.url) , "_blank");
>             }
>         }
>     }
> }
>
>
> HTH
>
>
>
>
> Steve
>