小小菜鸟的web菜园子

web开发学习。好记性不如烂笔头。每天进步一点点!

导航

使FLEX中TREE组件的某些特定的节点不能被选中.

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();">

    <mx:Script>
        <![CDATA[
            import mx.events.ListEvent;

            private function init():void 
{
                tree.openItems = dp..node;
            
}

            private function tree_itemClick(evt:ListEvent):void 
{
                var item
:Object = evt.currentTarget.selectedItem;
                var nonSelectable
:Boolean = ((item.hasOwnProperty("@clickable")) && (item.(@clickable == "false")));
                if (nonSelectable) {
                    tree.selectedItem = null;
                
}
            }
        ]]>
    </mx:Script>

    <mx:XML id="dp">
        <root>
            <node label="Parent 1 (X)" clickable="false">
                <node label="Child 1 (X)" clickable="false" />
                <node label="Child 2 (X)" clickable="false">
                    <node label="Grandchild 1" />
                    <node label="Grandchild 2" />
                </node>
                <node label="Child 3 (X)" clickable="false" />
                <node label="Child 4" />
            </node>
        </root>
    </mx:XML>

    <mx:Tree id="tree"
            dataProvider="
{dp}"
            showRoot="false"
            labelField="@label"
            width="200"
            itemClick="tree_itemClick(event);" />

</mx:Application>

来自:http://blog.flexexamples.com/2008/01/16/preventing-specific-items-from-being-selected-in-a-flex-tree-control/

posted on 2008-04-05 20:23  『小小菜鸟』  阅读(1600)  评论(0编辑  收藏  举报