如何在Adobe Flex中的DataGrid / AdvancedDataGrid中合并单元格 [英] How to merge cells in DataGrid/AdvancedDataGrid in Adobe Flex

查看:197
本文介绍了如何在Adobe Flex中的DataGrid / AdvancedDataGrid中合并单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

Flex(在我的理解中)并不直接提供。您有几个选项。

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

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

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

我看到的第一个选项将涉及直接将数据声明为高级数据格式的层次结构。如果您搜索层次结构的advanceddatagrid,您应该可以在线查找教程。

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.

或者,您可能希望始终显示数据,而不仅仅是展开父级。在这种情况下,您仍然需要层次模型,但您必须创建一个自定义的itemrenderer来表示一个父对象的所有子数据。 (在VBox / VGroup中有三个标签的itemrenderer可以为您提供的示例工作)

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 ::

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

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.

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

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";

对象有:

var field:Array = [];

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

这篇关于如何在Adobe Flex中的DataGrid / AdvancedDataGrid中合并单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆