---
title: "一个例子：不修改GataGrid选中的内容，实现可以复制GataGrid选中的内容"
author: "caiquan"
date: "2011-07-08T13:58:16Z"
tags: ["Flex", "Label控件"]
categories: ["Web前端"]
slug: "gatagrid-gatagrid"
draft: false
lastmod: "2011-07-08T13:58:16Z"
id: 1119563
url: "https://caiquan.iteye.com/blog/1119563"
---

代码如下test.mxml：

&lt;?xml version="1.0" encoding="utf-8"?&gt;  
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" &gt;  
    &lt;mx:Script&gt;  
        &lt;![CDATA[              
            \[Bindable]  
            private var dg\_item\_editor :ClassFactory = new ClassFactory(myItemEditor );  
            \[Bindable]  
            public var dg\_data :Array=[{'name':'Jack','sex':'男','age':'24'},  
                                      {'name':'Tom','sex':'女','age':'20'}];              
        ]]&gt;  
    &lt;/mx:Script&gt;     
&lt;mx:Panel&gt;  
    &lt;mx:DataGrid width="100%" height="100%" dataProvider="{dg\_data }" editable="true"&gt;  
                &lt;mx:columns&gt;  
                    &lt;mx:DataGridColumn dataField="name" itemEditor="{dg\_item\_editor }"/&gt;  
                    &lt;mx:DataGridColumn dataField="sex" itemEditor="{dg\_item\_editor }"/&gt;  
                    &lt;mx:DataGridColumn dataField="age" itemEditor="{dg\_item\_editor }"/&gt;  
                &lt;/mx:columns&gt;  
    &lt;/mx:DataGrid&gt;  
&lt;/mx:Panel&gt;  
&lt;/mx:Application&gt;

 

myItemEditor.mxml 代码如下：

&lt;?xml version="1.0" encoding="utf-8"?&gt;  
&lt;mx:TextInput xmlns:mx="http://www.adobe.com/2006/mxml" editable="false"/&gt;