Flex - 无法在 TitleWindow 内显示数据网格

发布于 2024-09-30 10:49:15 字数 875 浏览 4 评论 0原文

我试图在 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> 

在 titlewindow 中,它看起来像这样 - alt text

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

代码没有变化...

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

I'm trying to add a DataGrid inside a spark TitleWindow and for some reason its not showing up correctly.

When I put the same code in the main mxml, it comes up correctly. The exact same code shows up weird in the 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> 

Within the titlewindow it looks like this - alt text

In the main mxml it looks like this - alt text

There is no change in the code...

Can you please tell me whats happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

望她远 2024-10-07 10:49:15

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

My guess is that you have some sort of styles set for your title window that are getting inherited by your DataGrid. Hope that helps.

墨小墨 2024-10-07 10:49:15

另外,当您使用 FlexGlobals.topLevelApplication 打开此控件时,Flex 中似乎存在一个错误:

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

这发生在我的 DateField 控件上,因此我使用对“this”的调用来更改它,但需要注意的是它位于我的模块中而不是应用

Also there seems to be a bug in Flex when you open this up using FlexGlobals.topLevelApplication:

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

This happened to my DateField control, so I changed it using a call to "this" with the caveat that it is centered within my module and not the application

痴情 2024-10-07 10:49:15

的示例

这是 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>

,结果是:
alt text

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

Here is an example with your 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>

And the result is:
alt text

So re-check how you call/show your TitleWindow...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文