這是我的問題。我在mx:DataGrid列中有一個mx:Image。如果我沒有專門設置圖像的寬度和高度,當圖像加載到網格中時,只會顯示圖像的一部分。Flex DataGrid帶圖像 - 圖像沒有完全顯示
娛樂步驟:
- 創建新的Flex項目(桌面)
- 配置項目中使用Halo主題。
將下面的代碼添加到它們各自的位置 *注意:確保爲窗口應用程序分配了creationComplete事件。也可能需要一些調整任何進口聲明等。對不起。*
這是我遇到的問題的一個快速示例。當你啓動程序時,你會看到圖像的一部分。當您單擊重組時,將會出現完整圖像。
我試圖得到完整的圖像顯示在第一綁定,而不是第二沒有在MXML設置尺寸。我沒有成功通過ActionScript進行全圖像顯示,而沒有發生某種用戶交互。
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
{
BindData();
}
private function BindData():void
{
var objOrderItem:Object = new Object();
var items:ArrayCollection = new ArrayCollection(new Array(objOrderItem));
dgMain.dataProvider = new ArrayCollection(items.source);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox width="100%">
<mx:Button label="Rebind" click="BindData()" />
<mx:DataGrid id="dgMain" resizableColumns="false" draggableColumns="false"
sortableColumns="false" rowCount="1">
<mx:columns>
<mx:DataGridColumn headerText="Thumb" sortable="false" width="60">
<mx:itemRenderer>
<fx:Component>
<mx:HBox horizontalGap="0" verticalScrollPolicy="off" horizontalScrollPolicy="off" width="100%">
<mx:Image source="https://encrypted-tbn1.google.com/images?q=tbn:ANd9GcTTuc9n_oweh-dv4LUljzh0Lxzn1AvZchODUoSAeGePaDwPqUuw"
width="60" maintainAspectRatio="true" />
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
<mx:Label text="Text After Grid" />
</mx:VBox>
在此先感謝!
你好。我已經嘗試過延遲5-10秒,只是爲了踢腿,不幸的是它沒有更新圖像的效果。我已更新我的問題,以包含一些示例代碼,可以幫助您或任何人重新創建我遇到的問題。再次感謝。 – Agilis 2012-08-01 20:44:34