如何在Flex DataGrid插件Button itemRenderer周围添加间距?

时间:2021-09-22 19:41:24

I have a DataGrid with an drop-in Button itemRenderer:

我有一个带有插入按钮itemRenderer的DataGrid:

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

However, the button extends all the way both the right and left edge of the DataGridColumn. I've tried messing with the width properties and paddingLeft and paddingRight styles of both the DataGridColumn and the itemRenderer, but nothing seems to work.

但是,该按钮一直延伸到DataGridColumn的右边缘和左边缘。我已经尝试弄乱了DataGridColumn和itemRenderer的宽度属性和paddingLeft以及paddingRight样式,但似乎没有任何效果。

NOTE: I do not want to use a Container or UIComponent with the Button as a child as the itemRenderer - too much code.

注意:我不想使用带有Button作为子项的Container或UIComponent作为itemRenderer - 代码太多。

Is there a simple way to add left and right padding?

有没有一种简单的方法来添加左右填充?

2 个解决方案

#1


The button should only be as wide as you specified when you created it as a component, unless you created the component with 100% as the width. So, try a different percent width, a fixed pixel value, or (as you said you don't want to do) using a canvas based item renderer component with a button positioned inside of it.

除非您使用100%作为宽度创建组件,否则该按钮应仅与您在创建组件时指定的宽度相同。因此,尝试使用基于画布的项目渲染器组件以及位于其中的按钮,使用不同的百分比宽度,固定像素值或(如您所说,您不想这样做)。

#2


Well, I don't know about 'simple'... but it doesn't require a new class.

好吧,我不知道'简单'......但它不需要新的课程。

public var itemRenderer:ClassFactory ;

public var itemRenderer:ClassFactory;

[...]

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

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

[...]

#1


The button should only be as wide as you specified when you created it as a component, unless you created the component with 100% as the width. So, try a different percent width, a fixed pixel value, or (as you said you don't want to do) using a canvas based item renderer component with a button positioned inside of it.

除非您使用100%作为宽度创建组件,否则该按钮应仅与您在创建组件时指定的宽度相同。因此,尝试使用基于画布的项目渲染器组件以及位于其中的按钮,使用不同的百分比宽度,固定像素值或(如您所说,您不想这样做)。

#2


Well, I don't know about 'simple'... but it doesn't require a new class.

好吧,我不知道'简单'......但它不需要新的课程。

public var itemRenderer:ClassFactory ;

public var itemRenderer:ClassFactory;

[...]

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

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

[...]