I'm actually working on someone else code but I can't figure out something, I find the way the dataprovider is being accessed very peculiar in the mxml part.
extract 1 :
[Bindable]
public var adrDataList:ArrayCollection = new ArrayCollection();
[Bindable]
public var obj:Object = new Object();
extract 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);
this is the mxml part:
<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>
What I don't get is why is data.coordX is working? shouldn't it be data.obj.coordX
Thanks
Ps : I'm using flex SDK 3.5
List
component uses anItemRenderer
to display the list elements. TheList
uses object pooling to so that it creates only as manyItemRenderer
objects as necessary to display the list elements that are currently visible. When you scroll the list, it will re-use existing item renderers rather than creating new ones. To do this, the item renderer defines adata
property. So in the context of the item renderer, the current element in the data provider can be referenced by thisdata
property. – Sunil D.List
component above, but the same applies to the data grid components (the grids extendList
). Also, I referred to anItemRenderer
class which exists in Flex 4, in Flex 3 many compoents implement anIDataRenderer
interface (there was no formal ItemRenderer class). – Sunil D.