您的位置:首页 > 其它

Flex中如何通过itemClick事件,阻止用户点击选中Tree的某一分支节点

2009-06-09 00:31 736 查看
main.mxml

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

layout="vertical"

verticalAlign="middle"

backgroundColor="white">



<mx:Script>

<![CDATA[

import mx.events.ListEvent;



private function tree_itemClick(evt:ListEvent):void {

var item:Object = evt.currentTarget.selectedItem

if (tree.dataDescriptor.isBranch(item)) {

tree.selectedItem = null;

}

}

]]>

</mx:Script>



<mx:XML id="dp">

<root>

<node label="Parent 1">

<node label="Child 1" />

<node label="Child 2">

<node label="Grandchild 1" />

<node label="Grandchild 2" />

</node>

<node label="Child 3" />

<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐