[英]Does Spark Grid replace MX Grid?
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>
. 我想使用Spark Grid,但同时我意识到某些组件(如
<GridItem>
没有Spark等价物。
So, I mixed both Spark and Halo components in the program but when I ran it, I got the error: 所以,我在程序中混合了Spark和Halo组件,但是当我运行它时,我得到了错误:
"TypeError: Error #1034: Type Coercion failed: cannot convert spark.components::Grid@239b40a1 to mx.containers.Grid."
“TypeError:错误#1034:类型强制失败:无法将spark.components :: Grid @ 239b40a1转换为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>
The spark.components.Grid is not meant to replace the mx.containers.Grid . spark.components.Grid并不是要替换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.
相反,它立即使用是作为spark.components.DataGrid组件的一个组件,它用于呈现实现IList的数据提供程序中的项目。 See the language reference documentation on the Spark Grid for more details.
有关更多详细信息,请参阅Spark Grid上的语言参考文档。
You should continue to use the mx:Grid
. 您应该继续使用
mx:Grid
。 You can even find examples of it being used in the official Using Flex 4.5 reference: MX Grid layout container . 您甚至可以在官方使用Flex 4.5参考中找到它的示例: MX Grid布局容器 。
I will offer the observation, however, that you might also want to look at the s:Form container. 但是,我会提供观察,你可能还想查看s:Form容器。 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.
在我看来,排列前三行的方式更适合Form的设计用例。
Finally, the s:DataGrid
is intended to replace the mx:DataGrid
. 最后,
s:DataGrid
目的是取代的mx:DataGrid
。 So you should make sure to use that. 所以你应该确保使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.