【问题标题】:Flex - Unable to show datagrid inside a TitleWindowFlex - 无法在 TitleWindow 内显示数据网格
【发布时间】:2011-05-03 23:27:38
【问题描述】:

我正在尝试在 Spark TitleWindow 中添加一个 DataGrid,但由于某种原因它没有正确显示。

当我将相同的代码放入主 mxml 时,它会正确显示。完全相同的代码在 TitleWindow 中显示得很奇怪。

<mx:DataGrid x="10" y="51" width="535" height="215" id="musicianGrid">
    <mx:columns>
        <mx:DataGridColumn headerText="First Name" dataField="firstName" width="90"/>
        <mx:DataGridColumn headerText="Last Name" dataField="lastName" width="90"/>
        <mx:DataGridColumn headerText="Band/Group" dataField="bandName" />
        <mx:DataGridColumn headerText="Record Label" dataField="recordLabel" width="135"/>
    </mx:columns>
</mx:DataGrid> 

在标题窗口中它看起来像这样 -

在主 mxml 中它看起来像这样 -

代码没有变化...

你能告诉我发生了什么事吗?

【问题讨论】:

    标签: apache-flex actionscript-3 datagrid flex4


    【解决方案1】:

    我的猜测是您为标题窗口设置了某种样式,这些样式将被 DataGrid 继承。希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      当您使用 FlexGlobals.topLevelApplication 打开它时,Flex 中似乎也存在错误:

      var dialog:MyDialog = PopUpManager.createPopUp(FlexGlobals.topLevelApplication as DisplayObject, MyDialog, true) as MyDialog;
      

      这发生在我的 DateField 控件上,因此我使用对“this”的调用对其进行了更改,并注意它位于我的模块而不是应用程序的中心

      【讨论】:

        【解决方案3】:

        这是您的 DataGrid 的示例

        MainApp.mxml

        <?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">
            <fx:Script>
                <![CDATA[
                    import mx.managers.PopUpManager;
                    
                    protected function button1_clickHandler(event:MouseEvent):void
                    {
                        var pop:MyTitle = PopUpManager.createPopUp(this, MyTitle, true) as MyTitle;
                        PopUpManager.centerPopUp(pop);     
                    }
        
                ]]>
            </fx:Script>
            <s:Button label="Open" click="button1_clickHandler(event)"/>
        </s:Application>
        

        MyTitle.mxml

        <?xml version="1.0" encoding="utf-8"?>
        <s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
                       xmlns:s="library://ns.adobe.com/flex/spark" 
                       xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
            <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
            </fx:Declarations>
            <mx:DataGrid width="535" height="215" id="musicianGrid">
                <mx:columns>
                    <mx:DataGridColumn headerText="First Name" dataField="firstName" width="90"/>
                    <mx:DataGridColumn headerText="Last Name" dataField="lastName" width="90"/>
                    <mx:DataGridColumn headerText="Band/Group" dataField="bandName" />
                    <mx:DataGridColumn headerText="Record Label" dataField="recordLabel" width="135"/>
                </mx:columns>
            </mx:DataGrid> 
        </s:TitleWindow>
        

        结果是:

        所以重新检查你如何调用/显示你的 TitleWindow...

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2010-12-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-12-22
          • 1970-01-01
          • 2019-11-15
          相关资源
          最近更新 更多