我实际上正在研究其他人的代码,但我无法弄清楚一些事情,我发现在 mxml 部分中访问数据提供者的方式非常特殊。
提取 1:
[Bindable]
public var adrDataList:ArrayCollection = new ArrayCollection();
[Bindable]
public var obj:Object = new Object();
提取 2:
adrDataList.getItemAt(0).id = null;
adrDataList.getItemAt(0).natureVoie = null;
adrDataList.getItemAt(0).numeroVoie = null;
adrDataList.getItemAt(0).nomVoie = null;
adrDataList.getItemAt(0).commune = null;
adrDataList.getItemAt(0).complementAdresse = null;
adrDataList.getItemAt(0).codePostal = null;
obj.index = i;
obj.statutGeocodage = _model.service.getItemAt(i).statutGeocodage;
obj.coordX = "484646868"
obj.coordY = "455446846"
adrDataList.addItemAt(obj, 0);
这是 mxml 部分:
<view:CustomDataGrid id="dgAdr" height="80" width="989" allowMultipleSelection="true"
editable="{_model.isGeocodageActif}"
styleName="DataGrid" dataProvider="{adrDataList}" itemEditEnd="onEditItem(event)">
<view:columns>
<mx:DataGridColumn headerText="NumeroVoie" dataField="numeroVoie"/>
<mx:DataGridColumn headerText="NatureVoie" dataField="natureVoie"/>
<mx:DataGridColumn headerText="NomVoie" dataField="nomVoie"/>
<mx:DataGridColumn headerText="Commune" dataField="commune"/>
<mx:DataGridColumn headerText="CodePostal" dataField="codePostal"/>
<mx:DataGridColumn headerText="Géocod" editable="false">
<mx:itemRenderer>
<mx:Component>
<mx:Text text="{(data.coordX == 0)? '' : data.coordX} - {(data.coordY == 0)? '' : data.coordY}" />
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Géocodage" editable="false" dataField="statutGeocodage">
<mx:itemRenderer>
<mx:Component>
<formatter:geocodBtn color="{data.statutGeocodage}" horizontalAlign="center"
enabledBtns="{outerDocument._model.isGeocodageActif}"
click="outerDocument.onGeoClick(data.id, data.numeroVoie, data.natureVoie, data.nomVoie, data.commune, data.codePostal, data.idTechnicien, data.complementAdresse,event)">
</formatter:geocodBtn>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</view:columns>
</view:CustomDataGrid>
我不明白为什么 data.coordX 正在工作?不应该是 data.obj.coordX
谢谢
Ps:我正在使用 flex SDK 3.5