Flex 中树叶节点上的复选框

发布于 2024-08-05 03:19:02 字数 300 浏览 4 评论 0原文

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

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

我了解将复选框项渲染器应用到数据网格,但不应用到树上。

我正在使用 Flex Builder 3

I'm having difficulty getting checkboxes on only the leaf nodes of a tree.

Before anyone links it, I've seen http://www.sephiroth.it/file_detail.php?id=151# and this isn't exactly what I need. I don't want a 3-state checkbox system including both branch and leaf.

I understand applying the checkbox item renderer to a data grid but not on a tree.

I'm using Flex Builder 3

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷→糖丶微凉 2024-08-12 03:19:02

假设我们要将复选框放入 AdvancedDataGrid 的某一列中。我喜欢使用 HierarchicalData 或 HierarchicalCollectionView 作为我的数据网格的 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>

这应该是大部分。告诉我一下,谢谢!

Let's say that we want to put the Checkbox in one of the columns of AdvancedDataGrid. I like using HierarchicalData or HierarchicalCollectionView as my datagrid's 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>

That should be most of it. Let me know, thanks!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文