2010-11-17 37 views
0

我使用下面的代碼中插入一個DataGrid對象爲基本面板一個DataGrid(柔性)的細胞邊緣:更改內部

<mx:DataGrid borderThickness="0" 
    height="120" dataProvider="{collection}" 
    rowHeight="12" fontSize="9" 
    showHeaders="false" verticalGridLines="false"> 
    <mx:columns> 
     <mx:DataGridColumn dataField="field1" headerText="Field 1"/> 
     <mx:DataGridColumn dataField="field2" headerText="Field 2"/> 
    </mx:columns> 
</mx:DataGrid> 

我的設置都rowHeight和fontSize的屬性點是,我需要DataGrid緊湊,每行之間的空間非常小。但是通過這段代碼,我最終得到了大部分文本「截斷」:只有符號的上半部分出現在每一行上,其餘部分被一些空白空間切割。 這我猜是由於DataGrid單元格內的默認邊距,在顯示時優先於文本本身。 有沒有辦法解決這個問題? Adobe有什麼理由不讓保證金屬性設置? 感謝您的幫助。

回答

3

我建議你製作一個基於mx:標籤的自定義項目渲染器(如果你的情況只是文本),然後設置你需要的樣式。例如。 paddingTop /左/右/下。 你可以在這裏閱讀有關ItemRenderers的信息:Using an item renderer with an MX DataGrid control

+0

其實我發現DataGrid itslef擁有paddingTop/Bottom屬性,可以讓我改變行間的填充。然而,使用自定義項目渲染器允許更多的靈活性。謝謝 ! – Dunaril 2010-11-19 09:52:27