软硬度:自定义项目渲染组合框控件截断文本 [英] Flex: Custom Item Renderer For Combobox controls truncates text

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

问题描述

我实现了我使用的是同一个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和Label的宽度为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.

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

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