Spark Grid 会取代 MX Grid 吗?

发布于 2024-11-27 14:01:23 字数 2701 浏览 6 评论 0原文

我想使用 Spark Grid,但同时我意识到某些组件(例如 )没有 Spark 等效项。
因此,我在程序中混合了 Spark 和 Halo 组件,但当我运行它时,出现错误:

“TypeError:错误 #1034:类型强制失败:无法将 Spark.components::Grid@239b40a1 转换为 mx.containers.Grid。”

该计划:

<?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">

<s:Grid>  
    <mx:GridRow id="row1"> 
        <mx:GridItem>        
            <s:Label text="Description:"  paddingTop="5"/> 
        </mx:GridItem>     
        <mx:GridItem>      
            <s:TextArea id="descTI" width="300" height="50"/> 
        </mx:GridItem> 
    </mx:GridRow>    
    <mx:GridRow id="row2">  
        <mx:GridItem>        
            <s:Label text="Name:" paddingTop="5"/>   
        </mx:GridItem>        
        <mx:GridItem>     
            <s:TextInput id="nameTI" width="300"/>  
        </mx:GridItem>   
    </mx:GridRow>   
    <mx:GridRow id="row3">  
        <mx:GridItem>        
            <s:Label text="Target:" paddingTop="5"/> 
        </mx:GridItem>      
        <mx:GridItem> 
            <s:TextInput id="targetTI" width="300"/>     
        </mx:GridItem>   

    </mx:GridRow>  
    <mx:GridRow id="row5">   
        <mx:GridItem>  
            <s:Label text="Operand:" paddingTop="5" />  
        </mx:GridItem>   
        <mx:GridItem> 
            <mx:DataGrid id="attrDG">    
                <mx:columns>          
                    <mx:DataGridColumn dataField="variable" width="150"/>           
                    <mx:DataGridColumn dataField="level"           
                                       width="150"/>       
                </mx:columns>       
            </mx:DataGrid>    
        </mx:GridItem> 

        <mx:GridItem paddingLeft="3" colSpan="2"> 
            <mx:DataGrid id="attrDG0">    
                <mx:columns>          
                    <mx:DataGridColumn dataField="variable" width="150"/>           
                    <mx:DataGridColumn dataField="level"           
                                       width="150"/>       
                </mx:columns>       
            </mx:DataGrid>    
        </mx:GridItem>  
    </mx:GridRow> 
</s:Grid>
</s:Application>

I wanted to use the Spark Grid but at the same time I realized there are no Spark equivalents for certain components like the <GridItem>.
So, I mixed both Spark and Halo components in the program but when I ran it, I got the error:

"TypeError: Error #1034: Type Coercion failed: cannot convert spark.components::Grid@239b40a1 to mx.containers.Grid."

The program:

<?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">

<s:Grid>  
    <mx:GridRow id="row1"> 
        <mx:GridItem>        
            <s:Label text="Description:"  paddingTop="5"/> 
        </mx:GridItem>     
        <mx:GridItem>      
            <s:TextArea id="descTI" width="300" height="50"/> 
        </mx:GridItem> 
    </mx:GridRow>    
    <mx:GridRow id="row2">  
        <mx:GridItem>        
            <s:Label text="Name:" paddingTop="5"/>   
        </mx:GridItem>        
        <mx:GridItem>     
            <s:TextInput id="nameTI" width="300"/>  
        </mx:GridItem>   
    </mx:GridRow>   
    <mx:GridRow id="row3">  
        <mx:GridItem>        
            <s:Label text="Target:" paddingTop="5"/> 
        </mx:GridItem>      
        <mx:GridItem> 
            <s:TextInput id="targetTI" width="300"/>     
        </mx:GridItem>   

    </mx:GridRow>  
    <mx:GridRow id="row5">   
        <mx:GridItem>  
            <s:Label text="Operand:" paddingTop="5" />  
        </mx:GridItem>   
        <mx:GridItem> 
            <mx:DataGrid id="attrDG">    
                <mx:columns>          
                    <mx:DataGridColumn dataField="variable" width="150"/>           
                    <mx:DataGridColumn dataField="level"           
                                       width="150"/>       
                </mx:columns>       
            </mx:DataGrid>    
        </mx:GridItem> 

        <mx:GridItem paddingLeft="3" colSpan="2"> 
            <mx:DataGrid id="attrDG0">    
                <mx:columns>          
                    <mx:DataGridColumn dataField="variable" width="150"/>           
                    <mx:DataGridColumn dataField="level"           
                                       width="150"/>       
                </mx:columns>       
            </mx:DataGrid>    
        </mx:GridItem>  
    </mx:GridRow> 
</s:Grid>
</s:Application>

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

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

发布评论

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

评论(1

失退 2024-12-04 14:01:23

spark.components.Grid 是并不意味着取代 mx.containers.Grid。相反,它的直接用途是作为 的组件Spark.components.DataGrid 组件,用于在实现 IList 的数据提供程序中呈现项目。请参阅 Spark Grid 了解更多详情。

您应该继续使用mx:Grid。您甚至可以在官方使用 Flex 4.5 参考中找到使用它的示例:MX 网格布局容器

不过,我将提供观察结果,您可能还想查看 s:表单容器。在我看来,您布置前三行的方式似乎更适合表单设计的用例。

最后,s:DataGrid旨在取代mx:DataGrid。所以你应该确保使用它。

The spark.components.Grid is not meant to replace the mx.containers.Grid. Rather, it's immediate use is as a component of the spark.components.DataGrid component, which is meant to render items in a data provider which implements an IList. See the language reference documentation on the Spark Grid for more details.

You should continue to use the mx:Grid. You can even find examples of it being used in the official Using Flex 4.5 reference: MX Grid layout container.

I will offer the observation, however, that you might also want to look at the s:Form container. The manner in which you are laying out the first three rows seems to me more suited to the use case the Form was designed for.

Finally, the s:DataGrid is intended to replace the mx:DataGrid. So you should make sure to use that.

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