Flex,一个mx:Spark应用程序中的树组件,滚动条在折叠树节点时自动发送到顶部

时间:2011-07-11 04:43:06

标签: flex tree scrollbar flex-spark

Flex,一个mx:Spark应用程序中的树,当我折叠一个树节点时,滚动条将移动到顶部,测试代码如下:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" 
               creationComplete="init()">
<fx:Script>
    <![CDATA[
        import mx.collections.XMLListCollection;

        [Bindable]
        private var treeData:XML =
            <node label='root'>
                <node label="Monkeys">
                    <node label="South America">
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                    <node label="Africa" isBranch="true">
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                    <node label="Asia" isBranch="true">
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                </node>
                <node label="Sharks">
                    <node label="South America" isBranch="true">
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                    <node label="Africa" isBranch="true">
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                    <node label="Asia" >
                        <node label="Coastal"/>
                        <node label="Inland"/>
                    </node>
                </node>
            </node>;

        private function init():void{
            myTree.expandChildrenOf(myTree.firstVisibleItem, true);
        }
    ]]>
</fx:Script>
    <mx:Tree id="myTree" 
             y="50" 
             width="221" 
             height="207" 
             horizontalCenter="0"
             dataProvider="{treeData.node}"
             labelField="@label"/> 
</s:Application>

<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()"> <fx:Script> <![CDATA[ import mx.collections.XMLListCollection; [Bindable] private var treeData:XML = <node label='root'> <node label="Monkeys"> <node label="South America"> <node label="Coastal"/> <node label="Inland"/> </node> <node label="Africa" isBranch="true"> <node label="Coastal"/> <node label="Inland"/> </node> <node label="Asia" isBranch="true"> <node label="Coastal"/> <node label="Inland"/> </node> </node> <node label="Sharks"> <node label="South America" isBranch="true"> <node label="Coastal"/> <node label="Inland"/> </node> <node label="Africa" isBranch="true"> <node label="Coastal"/> <node label="Inland"/> </node> <node label="Asia" > <node label="Coastal"/> <node label="Inland"/> </node> </node> </node>; private function init():void{ myTree.expandChildrenOf(myTree.firstVisibleItem, true); } ]]> </fx:Script> <mx:Tree id="myTree" y="50" width="221" height="207" horizontalCenter="0" dataProvider="{treeData.node}" labelField="@label"/> </s:Application>

1 个答案:

答案 0 :(得分:2)

MX Tree存在许多令人惊讶的问题,例如在显示项目图标时尝试水平树滚动。

我建议您考虑迁移到名为Spark Tree的开源自定义组件。