我编写了非常简单的代码来理解columnstretch和calllater是如何工作的但是我无法使resizeGrid函数工作。这是怎么回事?
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var denemelist:ArrayCollection;
private function calculateHeight(l:int):Number{
return deneme.measureHeightOfItems(0, l) + deneme.headerHeight;
}
public function resizeGrid():void{
if(denemelist && deneme)
deneme.height = calculateHeight(denemelist.length);
}
public function preinit():void {
denemelist = new ArrayCollection([
{former:"sdfad", latter:"sdfgs"},
{former:"sdfgsd", latter:"sdfgsfd"}
]);
}
public function test():void {
denemelist.addItem({former:"sdfgsdf", latter:"sdfgdsgf"});
}
]]>
</mx:Script>
<mx:VBox width="100%" height="500">
<mx:DataGrid
width="100%"
resizeEffect="Resize"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
id="deneme"
variableRowHeight="true"
editable="false"
dataProvider="{denemelist}"
styleName="phrDataGrid"
columnStretch="callLater(resizeGrid)">
<mx:columns>
<mx:DataGridColumn dataField="former" headerText="former"/>
<mx:DataGridColumn dataField="latter" headerText="latter"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="deneme1" click="test()" />
</mx:VBox>
答案 0 :(得分:0)
我不认为在您调用该函数时数据网格已经更新。但您可以尝试不使用dg的高度,然后将rowCount设置为列表中的项目数。
HTH; 艾米