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

查看:19
本文介绍了如何在 Adob​​e 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)

我看到的第一个选项是直接将您的数据声明为高级数据网格的层次结构.如果您搜索分层高级数据网格,您应该可以在线找到教程.

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.

:

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

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

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