如何在flex树组件中选择childern节点?

时间:2011-08-01 09:31:57

标签: flex flex4 tree flashbuilder4 flash-builder4.5

如果我想检查父节点复选框意味着在childerns下方复选框将选择自动。

这是我的代码:

<fx:Script>
    <![CDATA[
        private function init():void    {
            httpTree.send();

        }

    ]]>
</fx:Script>
<fx:Declarations>
    <s:HTTPService id="httpTree" url="Assets/World.xml"  
                   resultFormat="e4x" useProxy="false" />
</fx:Declarations>
<mx:Tree dataProvider="{httpTree.lastResult.department}"
         id="treeTree" labelField="@name"   
         itemRenderer="com.ItemRenderForTree"  width="160" height="200" />

itemRenderer文件

<fx:Script>
    <![CDATA[
        protected function checkboxSelectHandler(event:Event):void
        {

        }
    ]]>
</fx:Script>


<s:states>
    <s:State name="normal" />            
    <s:State name="hovered" />
    <s:State name="selected" />
</s:states>
<s:HGroup left="0" right="0" top="0" bottom="0" verticalAlign="middle">
    <s:Rect id="indentationSpacer" width="{treeListData.indent}" percentHeight="100" alpha="0">
        <s:fill>
            <s:SolidColor color="0xFFFFFF" />
        </s:fill>
    </s:Rect>
    <s:Group id="disclosureGroup">
        <s:BitmapImage source="{treeListData.disclosureIcon}" visible="{treeListData.hasChildren}" />
    </s:Group>
    <s:BitmapImage source="{treeListData.icon}" />
    <s:CheckBox change="checkboxSelectHandler(event)" />
    <s:Label id="labelField" text="{treeListData.label}" paddingTop="2"/>
</s:HGroup>

i want out like this

任何人都可以帮助谢谢....

2 个答案:

答案 0 :(得分:0)

使用树dataDescriptor访问单击父节点的子节点。也许那会有所帮助?您的三个数据在datamodel中是否具有选定的属性?

答案 1 :(得分:0)

你正在寻找我一直称之为薛定谔复选框的东西。这是一段相同的代码,包括工作演示和adobe复选框的PNG资源。 Schrodinger Check Box