1 Reply Latest reply on May 29, 2012 5:48 AM by singhalkapil

    Using XMLLIST - Enable/Disable Menu Items

    singhalkapil

      I am using XMLList for creating menu items.

       

      I want to enable / disable menu items based on the permissions to the user.

       

      Below is the code snippet:

       

      <fx:XMLList  id="newData">

                                    <menuitem id="item1" label="{resourceManager.getString('taskmgmt', 'taskmgmt.label.newProject')}" />

                                    <menuitem id="item2" label="{resourceManager.getString('taskmgmt', 'taskmgmt.label.projectFromTemplate')}" enabled="false"/>

                          </fx:XMLList>

       

      private function ItemClickHandler(event:MenuEvent):void

                                    {

       

           if(PermissionManager.isAddPermitted("WTM_PROJECT_PLANNING")){

                                                             ProjectAssignmentModel.projectAssignmentFlag=false;

                                                             if(event.item.@label == resourceManager.getString('taskmgmt', 'taskmgmt.label.newProject')){

                                                                       clearModel();

                                                                       dispatchEvent(new SwitchViewEvent(SwitchViewEvent.SWITCH_VIEW_EVENT,false));

                                                        }

                                                        }

                                              }

       

       

      protected function newMenuButton_clickHandler(event:MouseEvent):void

                                    {

                                              if(! PermissionManager.isAddPermitted("WTM_PROJECT_PLANNING")){

                                                        newData.item1.enabled = false;

                                              }

                                              else

                                              {

                                                        menuList.dataProvider = newData;

                                                        menuList.show(event.stageX + 5 , event.stageY + 5);

                                                        mode = CREATE;

                                              }

                                    }

       

      Based on the permission, I want to dynamically enable / disable the "New Project" button.

       

      Can someone provide information how to achieve this ?

       

      Further update on this, it is giving the following error while running of the application:

       

      "TypeError: Error #1089: assignment to list with more than one item is not supported"