【发布时间】:2016-11-21 03:16:43
【问题描述】:
我正在使用 Flex 并试图让 sparks 数据网格垂直而不是水平制表。
var hBox:HBox = new HBox();
var templateDataGrid:spark.components.DataGrid = new spark.components.DataGrid();
templateDataGrid.dataProvider = dataGridList;
templateDataGrid.columns = columnHeaders;
templateDataGrid.sortableColumns = false;
templateDataGrid.editable = true;
hBox.addElement(templateDataGrid);
有一个非常简单的 as3 实现,我在 HBox 中渲染。
这是来自 API 的完整工作示例,我正在用 as3 而不是 mxml 编写我的网格,但我可以翻译。
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<s:Panel title="Spark DataGrid Control Example which demonstrates the variableRowHeight and rowHeight properties"
width="75%" height="75%"
horizontalCenter="0" verticalCenter="0">
<s:controlBarContent>
<s:HGroup verticalAlign="baseline">
<s:CheckBox label="variableRowHeight={dataGrid.variableRowHeight}" selected="@{dataGrid.variableRowHeight}"/>
<s:Label text=" "/> <!-- blank space -->
<s:HSlider minimum="12" maximum="120" value="@{dataGrid.grid.rowHeight}"/>
<s:Label text="rowHeight={dataGrid.grid.rowHeight}"/>
</s:HGroup>
</s:controlBarContent>
<s:DataGrid id="dataGrid" left="5" right="5" top="5" bottom="5" editable="true">
<s:ArrayCollection>
<s:DataItem key="1000" name="Abrasive" price="100.11" call="false"/>
<s:DataItem key="1001" name="Brush" price="110.01" call="true"/>
<s:DataItem key="1002" name="Clamp" price="120.02" call="false"/>
<s:DataItem key="1003" name="Drill" price="130.03" call="true"/>
<s:DataItem key="1004" name="Epoxy" price="140.04" call="false"/>
<s:DataItem key="1005" name="File" price="150.05" call="true"/>
<s:DataItem key="1006" name="Gouge" price="160.06" call="false"/>
<s:DataItem key="1007" name="Hook" price="170.07" call="true"/>
<s:DataItem key="1008" name="Ink" price="180.08" call="false"/>
<s:DataItem key="1009" name="Jack" price="190.09" call="true"/>
</s:ArrayCollection>
</s:DataGrid>
</s:Panel>
</s:Application>
如果您想查看网格,则可以在api here 中看到网格示例,并且当您使用 Tab 时,它会水平移动。我希望它垂直移动!
【问题讨论】:
-
这个stackoverflow.com/questions/4428871/… 可能会有所帮助
-
@www0z0k 如示例所示,
s:Datagrid不将其行和列显示为 DisplayObject,而是与 arraycollection 交互。所以这个链接与这个问题没有直接关系。
标签: actionscript-3 datagrid flex4.5