Hi all,
I have an urgent question concerning dataGrid column widhts.
Here is a simplified code:
<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml“
layout=”vertical” minWidth=”955″ minHeight=”600″ >
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable] private var dp:ArrayCollection = new ArrayCollection(
[
{id: 1, label: "Item one"},
{id: 2, label: "Item two"}
]);
public function init():void
{
}
]]>
</mx:Script>
<mx:DataGrid id=”dg” height=”100%” dataProvider=”{dp}”>
<mx:columns>
<mx:DataGridColumn headerText=”C1″ width=”200″ dataField=”label”/>
<mx:DataGridColumn headerText=”C2″>
<mx:itemRenderer>
<mx:Component>
<mx:HBox width=”100%” horizontalScrollPolicy=”off”>
<mx:Script>
<![CDATA[
import mx.controls.CheckBox;
override public function set data(value:Object):void
{
super.data = value;
for (var i:int = 0; i < 5; i++)
{
var cb:CheckBox = new CheckBox();
cb.label = "cb" + i;
contentHolder.addChild(cb);
}
}
]]>
</mx:Script>
<mx:HBox id=”contentHolder” width=”100%” horizontalScrollPolicy=”off”/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:Application>
As you can see, within the set data functions, content is added to the itemRenderer. This is done AFTER the datagrid is initialized.
Therefore, the column is not wide enough.
I have two problems now:
1. How can I calculate the widht of the contentHolder HBox?
2. How can I redraw the datagrid’s columns based on this calculated width?
Any help much appreciated.
Dany
|||
Renderers are not measured to determine column width. You will need to find a way to compute it upfront (or change it later)
Related posts:
- Datagrid colum item renderer HELP!!!!!
- datagrid addchild()
- Column widths in Spry dataset display
- Error when a DataGrid is edited
- Datagrid item renderer destroys on mouse over
Related posts brought to you by Yet Another Related Posts Plugin.