I have a datagrid where one column calls a custom an itemEditor like;
<mx:DataGridColumn dataField="city"
width="150"
head开发者_如何学JAVAerText="City"
itemEditor="components.ComboCity"
editorDataField="city"/>
And my custom itemEditor looks like;
<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
focusEnabled="true">
<mx:ComboBox id="comboBox"/>
<fx:Script>
<![CDATA[
public var myString:String;
.
.
.
How can I pass from my main application a value to myString
?
Take a look at this link, I think you will find your answer there :
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_3.html
Furher xp:
myGrid.editedItemRenderer.data.City=myEditor(myGrid.itemEditorInstance).setCity.text;
The best solution for me:
<mx:Script>
<![CDATA[
import mx.events.DataGridEvent;
private function itemEditorCreateHandle(event:DataGridEvent):void
{
ComboCity(DataGrid(event.target).itemEditorInstance).myString = "Put here the value";
}
]]>
</mx:Script>
<mx:DataGridColumn
dataField="city"
width="150"
headerText="City"
itemEditor="components.ComboCity"
itemEditorCreate="itemEditorCreateHandle(event);"
editorDataField="city"/>
You can always refer to parent component from itemRenderer by calling "outerDocument" property, e.g:
myString = outerDocument.componentProperty
http://livedocs.adobe.com/flex/3/html/help.html?content=cellrenderer_6.html
精彩评论