Pessoal tenho o seguinte problema estou tentando setar o valor em uma DataGrid no flex referentes ao objeto estado que possui um campo do tipo Pais que por sua vez possui o atributo paisNome como eu seto esse valor ? tentei da seguinte maneira :
<mx:DataGridColumn headerText="Pais Nome" width="100" dataField="estadoPais.paisNome"/>
mas o campo fica vazio.Na funcao que obtenho a resposta do servidor fiz o seguinte teste :
Alert.show((lista.toArray()[0] as Estado).estadoPais.paisNome);
Esse que por sua vez traz o nome do pais.Pois bem seria isso, espero que tenha sido claro e grato desde ja por possivel ajuda segue abaixo as classes e o mxml:
package com.localidade.entidade
{
[RemoteClass(alias="com.prs.pais.Pais")]
[Bindable]
public class Pais
{
public var paisId:Number;
public var paisNome:String;
public var paisSigla:String;
}
}
package com.localidade.entidade
{
import com.localidade.entidade.Pais;
[RemoteClass(alias="com.prs.estado.Estado")]
[Bindable]
public class Estado
{
public var estadoId:Number;
public var estadoNome:String;
public var estadoSigla:String;
public var estadoPais:Pais;
}
}
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%"
xmlns:componentes="com.prs.componentes.*"
creationComplete="init()">
<mx:Script>
<![CDATA[
import com.localidade.entidade.Estado;
import com.prs.ObjetoRemoto.ConstantesServicoId;
import com.prs.ObjetoRemoto.ObjetoRemoto;
import mx.collections.ArrayCollection;
import com.prs.entidades.Central;
import com.prs.eventos.LoginEvent;
import mx.rpc.remoting.mxml.RemoteObject;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.core.UIComponent;
import mx.managers.PopUpManager;
import com.localidade.entidade.Estado;
private function init(e:*=null):void
{
}
public function carregarEstados():void
{
var remoteObj:ObjetoRemoto = new ObjetoRemoto(ConstantesServicoId.ESTADO_ID_SERVICE);
remoteObj.addEventListener(ResultEvent.RESULT, fncOk);
remoteObj.addEventListener(FaultEvent.FAULT, fncFalha);
remoteObj.getOperation("listarEstados").send();
}
private function fncOk(e:ResultEvent):void
{
var lista:ArrayCollection = (e.result as ArrayCollection);
Alert.show((lista.toArray()[0] as Estado).estadoPais.paisNome);
grid.dataProvider = (e.result as ArrayCollection)
}
private function fncFalha(e:FaultEvent):void
{
Alert.show("Erro de conexão com o servidor ao carregar os estados!");
}
]]>
</mx:Script>
<mx:HBox x="10" bottom="10">
<componentes:BotaoPadrao label="Incluir" />
<componentes:BotaoPadrao label="Alterar" enabled="{grid.selectedItem != null}" />
<componentes:BotaoPadrao label="Excluir" enabled="{grid.selectedItem != null}"/>
</mx:HBox>
<mx:DataGrid id="grid" height="80%" right="10" left="10" top="10">
<mx:columns>
<mx:DataGridColumn headerText="Código" width="50" dataField="estadoId"/>
<mx:DataGridColumn headerText="Pais Nome" width="100" dataField="estadoPais.paisNome"/>
<mx:DataGridColumn headerText="Estado Nome " width="100" dataField="estadoNome"/>
<mx:DataGridColumn headerText="Estado Sigla" dataField="estadoSigla"/>
</mx:columns>
</mx:DataGrid>
</mx:Canvas>