How to make a table grid in Flex 4?
I want to make a grid with 3 images in a row and then should the next row start. How do I that in Flex 4? Are there any controls or can you do it with the Repeat开发者_Python百科er? Or am I forced to do some math on my own (modulus here we go again).
You may use a TileLayout
:
<s:DataGroup>
<s:layout>
<s:TileLayout />
</s:layout>
</s:DataGroup>
When a line is full, it goes to the next line automatically.
You could use a TileList
and set the columnCount property = 3.
Example:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/07/setting-a-specific-number-of-columns-in-a-tilelist-control-in-flex/ -->
<mx:Application name="TileList_columnCount_test"
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:ArrayCollection id="arrColl">
<mx:source>
<mx:Array>
<mx:Object label="One" />
<mx:Object label="Two" />
<mx:Object label="Three" />
<mx:Object label="Four" />
<mx:Object label="Five" />
<mx:Object label="Six" />
<mx:Object label="Seven" />
<mx:Object label="Eight" />
<mx:Object label="Nine" />
<mx:Object label="Ten" />
</mx:Array>
</mx:source>
</mx:ArrayCollection>
<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="columnCount:">
<mx:HSlider id="slider"
minimum="1"
maximum="5"
value="5"
snapInterval="1"
tickInterval="1"
liveDragging="true" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>
<mx:TileList id="tileList"
dataProvider="{arrColl}"
columnCount="{slider.value}"
columnWidth="100"
rowCount="2"
rowHeight="100"
verticalScrollPolicy="on" />
</mx:Application>
精彩评论