更改 DataGrid (Flex) 单元格内的边距

发布于 2024-10-02 17:20:15 字数 660 浏览 3 评论 0原文

我使用以下代码将 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

━╋う一瞬間旳綻放 2024-10-09 17:20:15

我建议您基于 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文