更改 DataGrid (Flex) 单元格内的边距
我使用以下代码将 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 不让设置 margin 属性有什么原因吗? 感谢您的帮助。
I am using the following code to insert a DataGrid object into a basic Panel:
<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>
My point for setting both rowHeight and fontSize properties is that I need the DataGrid to be compact, with very little space between each row. But with this code I end up with most of the text "truncated": only the upper part of the symbols appears on each row, and the rest is cut by some empty space.
This I guess is due to the default margins inside DataGrid cells, that take priority over the text itself when displaying.
Is there a way to fix this problem? And is there any reason why Adobe did not let the margin property be set?
Thanks for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您基于 mx:label 制作一个自定义项目渲染器(如果您的情况只是文本),然后设置您需要的样式。例如。内边距顶部/左/右/底部。
您可以在此处阅读有关 ItemRenderers 的信息:使用渲染项呃,有一个MX DataGrid 控件
I would suggest you make a custom item renderer based on mx:label ( if the case for you is text only ) and then set the styles you need. Eg. paddingTop/ left/right/bottom.
You can read about ItemRenderers here: Using an item renderer with an MX DataGrid control