Flex:Combobox 控件的自定义项目渲染器会截断文本 [英] Flex: Custom Item Renderer For Combobox controls truncates text

查看:25
本文介绍了Flex:Combobox 控件的自定义项目渲染器会截断文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现了一个自定义项目渲染器,我在我正在处理的 flex 项目上将它与组合框一起使用.它显示每个项目的图标和一些文本.唯一的问题是,当文本很长时,菜单的宽度没有正确调整,并且文本在显示时被截断.我已经尝试调整所有明显的属性来缓解这个问题,但没有取得任何成功.有谁知道如何使组合框菜单宽度适当地缩放到它呈现的任何数据?

I've implemented a custom item renderer that I'm using with a combobox on a flex project I'm working on. It displays and icon and some text for each item. The only problem is that when the text is long the width of the menu is not being adjusted properly and the text is being truncated when displayed. I've tried tweaking all of the obvious properties to alleviate this problem but have not had any success. Does anyone know how to make the combobox menu width scale appropriately to whatever data it's rendering?

我的自定义项渲染器实现是:

My custom item renderer implementation is:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"
    styleName="plain" horizontalScrollPolicy="off"> 

    <mx:Image source="{data.icon}" />
    <mx:Label text="{data.label}" fontSize="11" fontWeight="bold" truncateToFit="false"/>

</mx:HBox>

我的组合框是这样使用它的:

And my combobox uses it like so:

    <mx:ComboBox id="quicklinksMenu" change="quicklinkHandler(quicklinksMenu.selectedItem.data);" click="event.stopImmediatePropagation();" itemRenderer="renderers.QuickLinkItemRenderer" width="100%"/>

我应该澄清一下:我可以将组合框上的 dropdownWidth 属性设置为某个任意大的值 - 这将使一切都适合,但它会太宽.由于此组合框中显示的数据是通用的,我希望它自动将自身大小调整为数据提供程序中最大的元素(flex 文档说它会这样做,但我感觉我的自定义项渲染器以某种方式破坏了这种行为)

I should clarify on thing: I can set the dropdownWidth property on the combobox to some arbitrarily large value - this will make everything fit, but it will be too wide. Since the data being displayed in this combobox is generic, I want it to automatically size itself to the largest element in the dataprovider (the flex documentation says it will do this, but I have the feeling my custom item renderer is somehow breaking that behavior)

推荐答案

只是一个随机的想法(不知道这是否有帮助):

Just a random thought (no clue if this will help):

尝试将父 HBox 和标签的宽度设置为 100%.这通常解决了我遇到的任何类似问题.

Try setting the parent HBox and the Label's widths to 100%. That's generally fixed any problems I've run into that were similar.

这篇关于Flex:Combobox 控件的自定义项目渲染器会截断文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆