Conflicting Widgets

2607
2
05-03-2012 08:18 AM
RobertBrundage
New Contributor III
Hey guys;

I am working on a dashboard scenario.  I have created one Widget which is a series of radio buttons that turn on/off other widgets (the idea being that one click of the radiobutton will turn off all open widgets except for the radiobuttion selected widget.

This process is working just fine accept....

After clicking through the radiobuttons, one widget (which has 2 <viewer:WidgetTemplates) does not shut down all the way.  The layers are removed and one of the WidgetTemplates gets closed, but the other WidgetTemplate is staying open.

Anybody got any ideas or a solution to this?

<viewer:BaseWidget xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   xmlns:viewer="com.esri.viewer.*"
                   widgetConfigLoaded="init()">
    <fx:Script>
        <![CDATA[
            //this function called when the widget's configuration is loaded
   import com.esri.viewer.AppEvent;
   import com.esri.viewer.ViewerContainer;
   
   import mx.collections.ArrayCollection;
   import mx.collections.ArrayList;
   import mx.controls.Alert;
   import mx.utils.StringUtil;
   
   import spark.collections.Sort;
   import spark.collections.SortField;
   import spark.components.RadioButton;
   import spark.components.RadioButtonGroup;
   
   [Bindable]
   private var queryResultAC:ArrayCollection;
   
   [Bindable]
   private var widgetItems:ArrayCollection = new ArrayCollection();
   
      [Bindable]
   private var widgetItemsLbl:ArrayCollection = new ArrayCollection();
   
   [Bindable]
   private var rbtnLabelList:ArrayList;
   
            private function init():void
            {
                if (configXML) // checking for valid content in the configuration file
                {
     var rbList:XMLList = configXML..RadioButton;
     rbtnLabelList = new ArrayList();
     
     for (var i:int = 0; i < rbList.length(); i++)
     {
      rbtnLabelList.addItem(rbList.label);
     }
 
                  //  lbl.text = configXML.content || getDefaultString("helloContent");
                }
    // populateLoadedWidgets();
      getAllWidgetLabels();
            }
   
   private function populateLoadedWidgets():void
   {
    widgetItems.removeAll();
    for each (var widgetId:Number in ViewerContainer.getInstance().widgetManager.getAllLoadedWidgetIds())
    {
     var object:Object = new Object(); 
     object.id = widgetId;
     object.label = ViewerContainer.getInstance().widgetManager.getWidget(widgetId).widgetTitle;    
     widgetItems.addItem(object);
     //Alert.show(object.id + "   " + object.label);
    }
   }
   
   private function getAllWidgetLabels():void
   {
    widgetItemsLbl.removeAll();
    for (var i:uint = 0; i < configData.widgets.length; i++)
    {
     var object:Object = new Object();
     object.label = configData.widgets.label;
     object.id = configData.widgets.id;
     widgetItemsLbl.addItem(object);
    }
   }

   private function clearWidgets():void
   {
    populateLoadedWidgets();
 
    //getAllWidgetLabels()
    //Alert.show(String(widgetItems.length));
    for each (var widgetObj:Object in widgetItems)
    {
     Alert.show(widgetObj.id + "   " + widgetObj.label);
     if (widgetObj.label != "DPW Dashboard") 
     {
      AppEvent.dispatch(AppEvent.WIDGET_CLOSE, widgetObj.id);
     }
    }
   }
   
   private function getWidgets(event:Event):void
   {
    var radio:RadioButton = RadioButton(event.currentTarget);
    var strWidget:String = String(radio.getRepeaterItem());
    var widgetLbl:String;
    var widgetID:Number;
    var CurConProjID:Number;
    var WOID:Number;
    var LegID:Number;

    for each (var widgetObj:Object in widgetItemsLbl)
    {
    // Alert.show(widgetObj.label);
      if (widgetObj.label == strWidget)
     {
      AppEvent.dispatch(AppEvent.WIDGET_RUN, widgetObj.id);
     }
       }        
   }
  ]]>
    </fx:Script>
 
 
    <viewer:WidgetTemplate id="DPW_DB"
         fontSize="16"
                           width="300" height="300">
  <mx:VBox id="vb" horizontalGap="60">
   <mx:Repeater id="rbtnRepeater"
       dataProvider="{rbtnLabelList}">   
     <s:RadioButton groupName="Widgets" 
         id="rbtns"
         label="{rbtnRepeater.currentItem}" 
         width="100%"
         fontSize="16"
         click="clearWidgets();getWidgets(event)"/>
    </mx:Repeater>
  </mx:VBox>
    </viewer:WidgetTemplate>
</viewer:BaseWidget>
Tags (2)
0 Kudos
2 Replies
RobertBrundage
New Contributor III
So.....Am I so far off base that my question is not worth responding to?

Same problem exists.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Robert,

   You are likely running into a timing issue you can not just close multiple widgets in a loop you have to use a timer and delay the closing of the next widget by 700 milliseconds or more.
0 Kudos