【问题标题】:how to set truncateToFit option to true in the Tree in flex如何在 flex 中的 Tree 中将 truncateToFit 选项设置为 true
【发布时间】:2011-08-25 06:41:30
【问题描述】:

我正在尝试在我的自定义树中自定义 truncateToFit 选项。为了做到这一点,我必须将 LABEL 渲染到我的树中,因为树没有 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> 

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

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

【问题讨论】:

  • 我尝试在树渲染器中使用 truncateToFit,但它传递了一个错误.. 任何人都可以显示如何做到这一点的示例代码
  • 为什么不使用不可编辑的文本区域而不是标签。文本区域将负责将文本换行到下一行。

标签: apache-flex actionscript-3 tree itemrenderer custom-component


【解决方案1】:

您必须为该树使用项目渲染器 该项目渲染器将扩展 treeitemrenderer 组件。 它应该可以正常工作

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

【讨论】:

    【解决方案2】:

    你还需要设置 maxlines 或 maxDisplayedLines 为 1 来适应

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多