Apache flex 如何在flex中的树中将truncateToFit选项设置为true

Apache flex 如何在flex中的树中将truncateToFit选项设置为true,apache-flex,actionscript-3,tree,itemrenderer,custom-component,Apache Flex,Actionscript 3,Tree,Itemrenderer,Custom Component,我正在尝试在自定义树中自定义truncateToFit选项。为了做到这一点,我必须在我的树中呈现一个标签,因为树没有TruncateToFit属性。我比较喜欢flex,我经常上网查看他们是如何在树中渲染标签的,但我没有找到任何解决方案 我的预测正确吗?如果正确,那么如何在树组件内呈现标签 <ns1:PLTree verticalAlign="top" rendererIsEditor="true" columnWidth="150" height="100%" width="100%"

我正在尝试在自定义树中自定义truncateToFit选项。为了做到这一点,我必须在我的树中呈现一个标签,因为树没有TruncateToFit属性。我比较喜欢flex,我经常上网查看他们是如何在树中渲染标签的,但我没有找到任何解决方案

我的预测正确吗?如果正确,那么如何在树组件内呈现标签

<ns1:PLTree  verticalAlign="top" rendererIsEditor="true" columnWidth="150" height="100%" width="100%" x="0" y="0" borderThickness="0" dragEnabled="false" verticalScrollPolicy="auto" horizontalScrollPolicy="auto" dataProvider="{dBTree}"  iconFunction="getTreeIcon" labelField="label" iconField="icon" showRoot="false"  allowMultipleSelection="true" id="treTree" doubleClickEnabled="true" >
<ns1:itemRenderer>
    <mx:Component>
        <mx:Label truncateToFit="true" /> 
    </mx:Component>
</ns1:itemRenderer>
</ns1:PLTree> 

但如果我这样做,树的属性会被覆盖,所有内容都显示为文本。输出如下


请帮帮我。提前非常感谢。

您必须为该树使用项目渲染器 该项目渲染器将扩展treeitemrenderer组件。 它应该很好用

 <mx:Tree id="treeid"                                                                     
    width="100%" height="100%"  
    labelField="@label"                 
    itemRenderer="your renderer"/>


使用to fit时,还需要将maxlines或maxDisplayedLines设置为1

我尝试在树渲染器中使用truncateToFit,但它传递了一个错误。。请参考下面的链接,为什么不使用不可编辑的文本区域而不是标签。文本区域将负责将文本换行到下一行。