我发现我做错了什么,以防其他人尝试同样的事情,这是我的代码,错误出现在 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>