Flex - 垂直对齐数据网格中的单元格

发布于 2024-08-04 14:26:07 字数 140 浏览 5 评论 0原文

我在 Flex 的 DataGrid 单元格内垂直对齐文本时遇到问题。我在列上的 itemRenderer 中尝试了 this.setStyle("vertical-align", "middle) 但它似乎不起作用......我也尝试了verticalAlign。

I'm having trouble vertical aligning text inside cells in a DataGrid in Flex. I tried this.setStyle("vertical-align", "middle) in an itemRenderer on the column but it doesn't seem to work... I tried verticalAlign as well.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(5

汹涌人海 2024-08-11 14:26:07
try use <s:HorizontalLayout verticalAlign="middle">:


<s:GridColumn headerText="Action" >
 <s:itemRenderer>
   <fx:Component>
     <s:GridItemRenderer>
       <s:layout>
      <s:HorizontalLayout verticalAlign="middle" paddingLeft="5"/>
    </s:layout>
    <s:Button label="View"  click="outerDocument.view(event)" />
    <s:Button label="Unlink" click="outerDocument.unlink(event)"  />
  </s:GridItemRenderer> 
  </fx:Component>
</s:itemRenderer>    
</s:GridColumn> 
try use <s:HorizontalLayout verticalAlign="middle">:


<s:GridColumn headerText="Action" >
 <s:itemRenderer>
   <fx:Component>
     <s:GridItemRenderer>
       <s:layout>
      <s:HorizontalLayout verticalAlign="middle" paddingLeft="5"/>
    </s:layout>
    <s:Button label="View"  click="outerDocument.view(event)" />
    <s:Button label="Unlink" click="outerDocument.unlink(event)"  />
  </s:GridItemRenderer> 
  </fx:Component>
</s:itemRenderer>    
</s:GridColumn> 
孤星 2024-08-11 14:26:07

mx:Text 和 TextField 控件不直接支持 VerticalAlign 样式。

最简单的方法是对齐容器的内容,例如 container.setStyle("verticalAlign", "bottom") 等。

如果容器使用绝对布局,您可以将 topbottomleftright 样式之一设置为 < code>0,相应地对齐。

The mx:Text and TextField controls do not directly support a verticalAlign style.

The easiest would be to align the contents of their container e.g. container.setStyle("verticalAlign", "bottom") or so.

If the container uses absolute layout, you could set one of top, bottom, left, right styles to 0, to align accordingly.

虐人心 2024-08-11 14:26:07

使用DataGrid的verticalAlign属性(设置为“middle”)

verticalAlign:行中渲染器的垂直对齐方式

http://www.adobe.com/livedocs/flex/2/langref/mx/controls/DataGrid.html#styleSummary

Use the DataGrid verticalAlign property (set to "middle")

verticalAlign: The vertical alignment of a renderer in a row

http://www.adobe.com/livedocs/flex/2/langref/mx/controls/DataGrid.html#styleSummary

浪推晚风 2024-08-11 14:26:07

尝试在 DataGridColumn 上使用 textAlign。

Try textAlign on the DataGridColumn.

情痴 2024-08-11 14:26:07

看起来 Flex 本身并不支持它,但我找到了一个 hack 来完成这项工作。

让单元格继承一个 Box 并在盒子内放置一个标签。然后你可以在盒子上设置verticalAlign =“middle”。

Looks like flex doesn't support it natively but I found a hack to do the job.

Make the cells inherit a Box and put a label inside the box. Then you can set verticalAlign="middle" on the Box.

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