【问题标题】:Flex popup window opens up before data is set在设置数据之前会打开 Flex 弹出窗口
【发布时间】:2012-06-19 16:30:23
【问题描述】:

我有一个从按钮打开的弹出窗口 (selectReasonCode)。该按钮有以下代码

var selectReasonCode:SelectReasonCode = new SelectReasonCode();         
selectReasonCode.title = "Reason Codes";
selectReasonCode.showCloseButton = true;
PopUpManager.addPopUp(selectReasonCode, this, true);
PopUpManager.centerPopUp(selectReasonCode);             
selectReasonCode.updateReasons(reasonTypeId, rasonCds);  //This sets the dataprovider 

在选择原因代码屏幕上,我有一个数据网格,其中填充了 updateReasons 方法中设置的值(由上述方法调用。

问题是我的弹出屏幕打开为空。但是如果我在调试模式下在代码中添加一个断点并传递它,屏幕就会打开数据。我相信屏幕会在数据实际设置之前打开。这是真的吗?如果是这样,我如何确保在屏幕打开之前先执行 update Reasons 方法?

要排除调试模式...我在 updateReasons 代码后添加了一行以导致错误。因此首先显示错误,用户单击确定,然后打开弹出窗口。数据随即显示在弹出窗口中。

【问题讨论】:

    标签: apache-flex adobe popupwindow


    【解决方案1】:

    我相信屏幕会在数据实际设置之前打开。 这是真的吗?

    是的!

    如果是这样,我如何确保更新原因方法得到 在屏幕打开之前先执行?

    执行该方法,直到您取回数据后才显示弹出窗口。在调试模式下执行可能会给您在等待数据从远程服务器返回时所需的暂停;取决于调试点在哪里。

    但是,您可以像这样移动 updateReasons 方法调用:

    var selectReasonCode:SelectReasonCode = new SelectReasonCode();         
    selectReasonCode.title = "Reason Codes";
    selectReasonCode.showCloseButton = true;
    selectReasonCode.updateReasons(reasonTypeId, rasonCds);  //This sets the dataprovider 
    PopUpManager.addPopUp(selectReasonCode, this, true);
    PopUpManager.centerPopUp(selectReasonCode);             
    

    但是,在 updateReasons 触发异步服务调用的假设下,您必须等到数据返回后才能显示弹出窗口。概念上是这样的:

    // first make your pop up component an instance variable instead of a local variable to the method
    protected var selectReasonCode:SelectReasonCode;         
    
    
    // in your method; create the instance like nromal 
    selectReasonCode:SelectReasonCode = new SelectReasonCode();
    selectReasonCode.title = "Reason Codes";
    selectReasonCode.showCloseButton = true;
    selectReasonCode.updateReasons(reasonTypeId, rasonCds);  //This sets the dataprovider  
    selectReasonCode.addEventListener('someEventThatTellsMeDataIsReturn',onPopUpDataReturn);
    
    
    // finally in your data is available method, display the pop up using the PopUpManager
    protected function onPopUpDataReturn(event:Event):void{
      PopUpManager.addPopUp(selectReasonCode, this, true);
      PopUpManager.centerPopUp(selectReasonCode);             
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-01
      • 2013-10-17
      • 1970-01-01
      • 1970-01-01
      • 2011-02-16
      • 1970-01-01
      相关资源
      最近更新 更多