我需要能够使高级数据网格的一列可编辑,以便我的最终用户可以通过剪贴板右键单击并将数据从其复制到另一个源。
我希望在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;
}
答案 0 :(得分: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>