0
votes

I need the ability to make one column of an advanced data grid editable so my end user can right click and copy the data from it to another source via there clipboard.

I am looking to implement the following code in an advanceDataGrid and not just a standard Datagrid but for some reason it is not functioning, I have it implemented in another page as a dataGrid and that is working correctly.

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;
}
1
I figured out what I had wrong, in case anyone else has attempts the same thing here is my code the error was in the 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; }Dye

1 Answers

0
votes

I figured out what I had wrong, in case anyone else has attempts the same thing here is my code the error was in the 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;
 }

Here is the NonEditableTextInputRender.mxml that allows the end user to copy the text but not alter it in any other manner and only for one column in the advanced data grid.

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