6 Replies Latest reply on Mar 8, 2012 10:04 AM by jfb00

    Hide menu item

    jfb00 Level 3

      Hi,

      I can disable an item from a menu item, but it is a way to hide completely the option from a menu?

      It is any menu component up there with this functionality?

      Thanks

        • 1. Re: Hide menu item
          Carol L. Frampton Level 2

          Which menu are you talking about?

          • 3. Re: Hide menu item
            Carol L. Frampton Level 2

            Read the section called "About Menu Data Providers - Collections" in http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7b1e.html.

            • 4. Re: Hide menu item
              jfb00 Level 3

              Good Link,

              The solution is: if I have 4 types of logins them create 4 different arrayCollections of Data with menu items for each login type and make the selection at the time of loading the app.

              Am I correct?

              Thanks!

              • 5. Re: Hide menu item
                Carol L. Frampton Level 2

                Or you can have one ArrayCollection which you manipulate using the methods in ArrayCollection (addItem, removeItem, etc) to have the correct items for the login type.  If your dataProvider is anything that implements ICollectionView, mx:Menu will listen for the collection change events (CollectionEvents) and update the menu accordingly.

                 

                Alternatively you can change the dataProvider.

                • 6. Re: Hide menu item
                  jfb00 Level 3

                  I don't see much examples up there. Here is one:

                   

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

                  <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                                 xmlns:s="library://ns.adobe.com/flex/spark"

                                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">

                      <fx:Declarations>

                          <!-- Place non-visual elements (e.g., services, value objects) here -->

                      </fx:Declarations>

                      <fx:Script>

                          <![CDATA[

                              import mx.collections.ArrayCollection;

                             

                              [Bindable] private var menuData:ArrayCollection = new ArrayCollection;

                              [Bindable] private var loginVar:Number = 0;

                             

                              private function init():void{

                                  var temp:Array = new Array();

                                  var subNodes:ArrayCollection = new ArrayCollection ([{label:"New"},{label:"Open"},{label:"Close"}]);

                                  temp.push({label:"File",children:subNodes});

                   

                                  temp.push({label:"Edit"});

                                  temp.push({label:"Source"});

                                 

                                  subNodes = new ArrayCollection([ {label:"50%"},{label:"100%"} ]);

                                  temp.push({label:"View",children:subNodes});

                                 

                                  if (loginVar == 1){

                                      subNodes = new ArrayCollection([ {label:"Users"},{label:"Accounts"} ]);

                                      temp.push({label:"Admin",children:subNodes});

                                  }

                                 

                                  menuData = new ArrayCollection(temp);

                              }

                         

                          ]]>

                      </fx:Script>

                      <mx:MenuBar id="Menu" dataProvider="{menuData}" />

                  </s:Application>