我很难在 树的叶节点上获取复选框。

在有人链接之前,我已经看过 http://www.sephiroth .it / file_detail.php?id = 151#这不是我需要的。我不想要一个包含分支和叶子的3状态复选框系统。

我理解将复选框项目渲染器应用于数据网格而不是树上。

我正在使用Flex Builder 3

有帮助吗?

解决方案

假设我们要将Checkbox放在AdvancedDataGrid的其中一列中。我喜欢使用HierarchicalData或HierarchicalCollectionView作为我的datagrid的dataProvider:

// TestGrid
<mx:AdvancedDataGrid id="myADG">
    <mx:columns>
        <AdvancedDataGridColumn id="col1" />
        <AdvancedDataGridColumn id="col2" itemRenderer="LeafCheckbox" />
    </mx:columns>
</mx:AdvancedDataGrid>



// LeafCheckBox.mxml
<mx:Box 
    creationComplete="init(event)"
    implements="IDropInListItemRenderer">
<mx:Script>
    <![CDATA[

    // Internal variable for the property value.
    private var _listData:BaseListData;

    // Make the listData property bindable.
    [Bindable("dataChange")]

    // Define the getter method.
    public function get listData():BaseListData
    {
      return _listData;
    }

    // Define the setter method,
    public function set listData(value:BaseListData):void
    {
      _listData = value;
    }


    private function init(event:Event):void {
        var dg:AdvancedDataGrid = this.listData.owner.parent as AdvancedDataGrid;
        if (!dg.dataProvider.hasChildren(dg.selectedItem))
            this.addChild(new CheckBox());
    }

    ]]>
</mx:Script>

</mx:Box>

应该是大部分内容。让我知道,谢谢!

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top