【问题标题】:How can I add spacing around a Flex DataGrid drop-in Button itemRenderer?如何在 Flex DataGrid 插入式按钮 itemRenderer 周围添加间距?
【发布时间】:2010-11-16 11:07:06
【问题描述】:

我有一个DataGrid 和一个插入式Button itemRenderer

<mx:DataGridColumn headerText="" width="135" 
    itemRenderer="ActionButtonItemRenderer" />

但是,该按钮一直延伸到DataGridColumn 的左右边缘。我试过弄乱widthDataGridColumnitemRendererwidth 属性和paddingLeftpaddingRight 样式,但似乎没有任何效果。

注意:我不想将 ContainerUIComponent 与作为 itemRenderer 的子按钮一起使用 - 代码太多。

有没有简单的方法来添加左右内边距?

【问题讨论】:

  • 为什么说使用 Container 或 UIComponent 代码太多?你是从可读性的角度说的吗?

标签: apache-flex actionscript-3 coding-style padding itemrenderer


【解决方案1】:

按钮的宽度只能与您在将其创建为组件时指定的一样宽,除非您创建的组件具有 100% 的宽度。因此,请尝试使用不同的百分比宽度、固定的像素值,或者(如您所说,您不想这样做)使用基于画布的项目渲染器组件,其中包含一个按钮。

【讨论】:

  • 正如我在原始问题中所述,在 itemRenderer 类和 DataGrid 列中的一个或两个上设置显式宽度对按钮的大小没有影响。它只是填充列宽。
【解决方案2】:

嗯,我不知道“简单”...但它不需要新类。

public var itemRenderer:ClassFactory ;

[...]

itemRenderer = new ClassFactory(ActionButtonItemRenderer); itemRenderer.properties = "{width:135}";

[...]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-09
    • 2018-06-07
    • 1970-01-01
    • 2012-01-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多