0

我需要能够使高级数据网格的一列可编辑,以便我的最终用户可以右键单击并通过剪贴板将数据从其中复制到另一个源。

我希望在 AdvanceDataGrid 中实现以下代码,而不仅仅是标准 Datagrid,但由于某种原因它无法正常工作,我将它作为 dataGrid 在另一个页面中实现,并且工作正常。

import com.jpmc.ctrbs.dashboard.alarms.renderers.NonEditableTextInputEditor;

if(dataFields[i] == 'EVENT_DESCRIPTION') {
dataGridColumn.editable = true;
dataGridColumn.itemEditor = new mx.core.ClassFactory(NonEditableTextInputEditor);
dataGridColumn.editable = false;
}
4

1 回答 1

0

我发现我做错了什么,以防其他人尝试同样的事情,这是我的代码,错误出现在 if(dataFields[i] == 'EVENT_DESCRIPTION'){

 import com.jpmc.ctrbs.dashboard.alarms.renderers.NonEditableTextInputEditor;

 if(dataGridColumn.dataField == "EVENT_DESCRIPTION") {
 dataGridColumn.editable = true;
 dataGridColumn.itemEditor = new mx.core.ClassFactory(NonEditableTextInputEditor);
 }
 else {
 dataGridColumn.editable = false;
 }

这是 NonEditableTextInputRender.mxml,它允许最终用户复制文本,但不能以任何其他方式更改它,并且仅限于高级数据网格中的一列。

 <?xml version="1.0" encoding="utf-8"?>
 <mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009" 
     xmlns:s="library://ns.adobe.com/flex/spark" 
     xmlns:mx="library://ns.adobe.com/flex/mx"
     horizontalScrollPolicy="off">

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.FlexEvent;

        [Bindable]
        public var text:String = "";

        override public function set data(value:Object):void {
            super.data = value;
            else if(value && value.EVENT_DESCRIPTION ) {
                try {
                    textInput.text = value.EVENT_DESCRIPTION;
                    text = value.EVENT_DESCRIPTION;
                    textInput.selectionBeginIndex = 0;
                    textInput.selectionEndIndex = text.length;
                    textInput.selectRange(0,text.length);
                }catch(err:Error) {
                }
            }
        }

        protected function textInput_clickHandler(event:MouseEvent):void
        {
            else if(data && data.EVENT_DESCRIPTION) {
                try {
                    textInput.text = data.EVENT_DESCRIPTION;
                    text = data.EVENT_DESCRIPTION;
                    textInput.selectionBeginIndex = 0;
                    textInput.selectionEndIndex = data.EVENT_DESCRIPTION.toString().length;
                    textInput.selectRange(0,data.EVENT_DESCRIPTION.toString().length);
                }catch(err:Error) {
                }
            }
        }



    ]]>
</fx:Script>

<mx:TextInput  id="textInput" editable="false" doubleClick="textInput_clickHandler(event)"  maxChars="1000"  />
 </mx:Canvas>
于 2013-10-28T14:37:51.777 回答