如何在 Adob​​e Flex 中合并 DataGrid/AdvancedDataGrid 中的单元格

发布于 2024-11-27 14:26:04 字数 90 浏览 0 评论 0原文

我需要合并单元格,如图所示:

在此处输入图像描述

I need to merge the cells as shown in the picture:

enter image description here

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

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

发布评论

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

评论(1

猫弦 2024-12-04 14:26:04

Flex(以我的理解)并没有直接提供这一点。你有几个选择。

无论哪种方式,您可能需要在分层模型中排列数据。 (有 3 个孩子的父母似乎描述了您的问题)

我看到的第一个选项涉及直接将您的数据声明为高级数据网格的分层结构。如果您搜索分层高级数据网格,您应该能够在线找到教程。

或者,您可能希望始终显示数据,而不仅仅是在展开父级时显示。在这种情况下,您仍然需要分层模型,但您必须创建一个自定义 itemrenderer,能够表示一个父对象的所有子数据。 (VBox/VGroup 中具有三个标签的 itemrenderer 适用于您给出的示例)

如果这些没有帮助,或者您想了解一个解决方案或另一个解决方案的更多详细信息,请随时在评论中询问。

编辑::

作为 itemrenderer 的示例,这里是我使用过的类似 itemrenderer 的来源。 (我的只填充两个标签,但是如果您了解它在做什么,您应该能够扩展它)

<VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
    implements="mx.controls.listClasses.IDropInListItemRenderer"
    width="100%" height="100%" 
    verticalGap="0" paddingTop="5" paddingBottom="5" 
    horizontalScrollPolicy="off"
    horizontalAlign="center">

    <mx:Script>
        <![CDATA[
            import mx.controls.Label;
            import mx.controls.dataGridClasses.DataGridListData;
            import mx.controls.listClasses.BaseListData;

            private var _listData:BaseListData;

            [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;
            }

        override public function set data(value:Object):void
        {
            removeAllChildren();

            if (value != null)
            {
                var myListData:DataGridListData = DataGridListData(listData);

                var lLabel1:Label = new Label();
                var lLabel2:Label = new Label();


                lLabel1.text = value[myListData.dataField][0];
                lLabel1.percentWidth = 0;
                addChild(lLabel1);

                lLabel2.text = value[myListData.dataField][1];
                lLabel2.percentWidth = 0;
                addChild(lLabel2);
            }

        } 
        ]]>
    </mx:Script>
</VBox>

我删除了很多专有代码,所以如果它没有任何意义,请告诉我。

这是为了可重用,因此值[myListData.dataField],但如果您愿意,您可以通过自己定义字段轻松地使其更加具体。此特定代码需要以下格式的数据,例如:

value[field][0] = "text1";
value[field][1] = "text2";

对象具有:

var field:Array = [];

field[0] = "text1";
field[1] = "text2";

Flex (in my understanding) does not directly provide this. You have a few options.

Either way, you may need to arrange your data in a hierarchical model. (Parent with 3 children appears to describe your question)

The first option I see would involve directly declaring your data as hierarchical to the advanceddatagrid. If you search for hierarchical advanceddatagrid you should be able to find tutorials online.

Alternatively, you may desire to always have the data show, and not only when you expand the parent. In this case, you will still need the hierarchical model, but you will have to create a custom itemrenderer able to represent all of the children data for one parent object. (an itemrenderer with three labels in a VBox/VGroup would work for the example you've given)

If these don't help, or you would like more detail on one solution or the other, feel free to ask in a comment.

EDIT::

As an example of the itemrenderer, here's the source of a similar itemrenderer I've used. (mine only populates two labels, but you should be able to extend it if you understand what it's doing)

<VBox xmlns:mx="http://www.adobe.com/2006/mxml" 
    implements="mx.controls.listClasses.IDropInListItemRenderer"
    width="100%" height="100%" 
    verticalGap="0" paddingTop="5" paddingBottom="5" 
    horizontalScrollPolicy="off"
    horizontalAlign="center">

    <mx:Script>
        <![CDATA[
            import mx.controls.Label;
            import mx.controls.dataGridClasses.DataGridListData;
            import mx.controls.listClasses.BaseListData;

            private var _listData:BaseListData;

            [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;
            }

        override public function set data(value:Object):void
        {
            removeAllChildren();

            if (value != null)
            {
                var myListData:DataGridListData = DataGridListData(listData);

                var lLabel1:Label = new Label();
                var lLabel2:Label = new Label();


                lLabel1.text = value[myListData.dataField][0];
                lLabel1.percentWidth = 0;
                addChild(lLabel1);

                lLabel2.text = value[myListData.dataField][1];
                lLabel2.percentWidth = 0;
                addChild(lLabel2);
            }

        } 
        ]]>
    </mx:Script>
</VBox>

I removed a lot of proprietary code, so if it doesn't make any sense let me know.

This is intended to be reusable, hence the value[myListData.dataField], but if you want you can easily make it a lot more specific by defining the fields yourself. This particular code expects the data in the following format, for example:

value[field][0] = "text1";
value[field][1] = "text2";

Object has:

var field:Array = [];

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