Flex树不会显示标签,只显示图标

时间:2011-08-05 16:42:22

标签: flex tree

我得到了文件夹图标,而不是标签。我尝试了很多数据源,总是一样的。文件,ajax调用,文本,它总是失败。

在下面的代码中,我甚至设置了一个自定义处理程序并观察XML进来,我设置了一个静态文本标签。从来没有显示过没有标签功能并使用labelField会发生这种情况。是的,我100%确定该属性匹配。再次,尝试了许多不同的数据源。

我不知道什么会遮挡文字,而不是图标。但我也检查了这一点。

尝试this simple one file example,编译得很好。

完整代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:HGroup xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%">
<fx:Declarations>       
    <fx:XML id="selectedData2" source="assets/xml/orgchartmodel.xml"/>
</fx:Declarations>

<fx:Script>
    <![CDATA[   

        private function tree_labelFunc(item:XML):String {
            var label:String;

            label = "flexisshit";  //breakpoint hits here but I never see this text

            return label;
        }           
    ]]>
</fx:Script>

<mx:Tree id="tree" dataProvider="{selectedData2}" labelFunction="tree_labelFunc" width="100%" height="100%"  showRoot="false" textDecoration="underline" textSelectedColor="0xFFCCFF" depthColors="[#FFFFFF, #EEEEEE, #DDDDDD, #CCCCCC, #BBBBBB, #AAAAAA]" />
</s:HGroup>

上面使用的XML文件(仅显示部分)

<employee layout="default" name="Eric Joplin" email="ejoplin@yoyodyne.com" phone="555-0100" fax="555-0101" businessUnit="Management" status="present" gender="male">
<employee name="Gary Roberts" layout="left_below" email="groberts@yoyodyne.com" phone="555-0100" fax="555-0101" businessUnit="Logistics" status="present" gender="male">
<employee layout="default" name="Alexander Burns" email="aburns@yoyodyne.com" phone="555-0102" fax="555-0103" businessUnit="Logistics" status="present" gender="male"/>
<employee layout="default" name="John Conner" email="jconner@yoyodyne.com" phone="555-0104" fax="555-0105" businessUnit="Logistics" status="present" gender="male"/>
</employee>
<employe ....

1 个答案:

答案 0 :(得分:1)

我测试了你的代码,它适用于我所以我猜你有一个css或某些代码嵌入字体的代码。尝试直接在mx:Tree

上将fontFamily设置为Verdana
<mx:Tree id="tree"
         fontFamily="Verdana"
         width="100%" height="100%"
         textDecoration="underline"
         textSelectedColor="0xFFCCFF"
         dataProvider="{xmlListColl}"
         labelFunction="tree_labelFunc"
         showRoot="false"
         depthColors="[#FFFFFF, #EEEEEE, #DDDDDD, #CCCCCC, #BBBBBB, #AAAAAA]"
         />
相关问题