Olá é assim dataField="{usuario.nome}" /> acho que é isso que faltou ou
entao dataField="{nome}" /> veja e de um retorno se deu certo.
At.
Kleber Gracia Soares
Equipe Galaxyz trabalhando para você
www.galaxyz.com.br
Telefone: |44| 3233-2039
Cel.: |44| 9960-0298 - Tim
Msn: [email protected]
Skype: kleber.gracia
Email: [email protected]
"Tudo posso naquele que me fortalece!" (Fl 4,13).Em 1 de setembro de 2010 09:52, claudemir <[email protected]> escreveu: > Bom dia > No meu dataGrid tenho uma lista de pagamento e cada pagamento > pertence a um usuario, no entanto não sei como mostrar o nome do > usuario no dataGrid, Tentei fazer assim mas não mostrou nada. > <mx:DataGridColumn headerText="Usuario" dataField="usuario.nome" /> > </mx:columns> > > Segue abaixo as minhas classes. > > package com.digows.artigos.JavaFlex.view.entity > { > import mx.collections.ArrayCollection; > > > [RemoteClass(alias="com.digows.artigos.JavaFlex.model.entity.Usuario")] > [Bindable] > public class Usuario > { > public var id:Number; > public var nome:String; > public var login:String; > public var senha:String; > > public var listPagamentos:ArrayCollection; > > public function Usuario() > { > listPagamentos = new ArrayCollection(); > } > > } > } > > ----------------------------------------------------------------------------------------- > package com.digows.artigos.JavaFlex.view.entity > { > > [RemoteClass(alias="com.digows.artigos.JavaFlex.model.entity.Pagamento")] > [Bindable] > public class Pagamento > { > public var id:Number; > public var dataPagamento:Date; > public var dataVencimento:Date; > public var valorPagamento:Number; > public var valorVencimento:Number; > public var obs:String; > public var status:Status; > public var usuario:Usuario; > > public function Pagamento() > { > status = new Status(); > usuario = new Usuario(); > this.status = status; > } > > } > } > > <?xml version="1.0" encoding="utf-8"?> > <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" > creationComplete="getList()" width="100%" height="100%"> > > <mx:Panel id="panelPagamento" layout="absolute" title="Controle de > Pagamento teste" width="100%" height="100%"> > > <mx:Label text="Id:" x="10" y="10"/> > <mx:TextInput id="idTxt" editable="false" enabled="false" > text="{Pagamento(dgPagamento.selectedItem).id}" x="34" y="8" > width="72"/> > > <mx:Label text="Pagamento" x="124" y="10"/> > > <mx:Label text="Vencimento" x="124" y="36"/> > <mx:DateField id="dtdataPagamento" formatString="DD/MM/YYYY" > > > text="{dateFormatter.format(Pagamento(dgPagamento.selectedItem).dataPagamento)}" > x="201" y="34" width="107" /> > > <mx:DateField id="dtdataVencimento" formatString="DD/MM/YYYY" > > > text="{dateFormatter.format(Pagamento(dgPagamento.selectedItem).dataVencimento)}" > x="201" y="8" width="107" /> > > <mx:TextInput id="valorPagamentoTxt" > text="{Pagamento(dgPagamento.selectedItem).valorPagamento}" x="375" > y="8" width="133"/> > <mx:Label text="Valor" x="334" y="10"/> > <mx:Label text="Valor" x="334" y="36"/> > <mx:TextInput id="valorVencimentoTxt" > text="{Pagamento(dgPagamento.selectedItem).valorVencimento}" x="375" > y="34" width="133"/> > > <mx:ComboBox id="combo_usuarios" > dataProvider="{listUsuarios}" > labelField="nome" x="201" y="64" width="211" /> > > <mx:DataGrid id="dgPagamento" > dataProvider="{listPagamentos}" width="100%" > height="130" y="94"> > <mx:columns> > <mx:DataGridColumn headerText="ID" > width="30" dataField="id"/> > <mx:DataGridColumn headerText="Pagamento" > dataField="dataPagamento" labelFunction="formatDate"/> > <mx:DataGridColumn headerText="Valor" > dataField="valorPagamento" / > > > <mx:DataGridColumn headerText="Vencimento" > dataField="dataVencimento" labelFunction="formatDate"/> > <mx:DataGridColumn headerText="Valor" > dataField="valorVencimento" > labelFunction="formatMoney" /> > <mx:DataGridColumn headerText="Usuario" > dataField="usuario.nome" / > > > </mx:columns> > </mx:DataGrid> > <mx:ControlBar horizontalAlign="center"> > <mx:Button label="Novo" id="btNovo" click="setDefault()" > icon="@Embed('icons/novo2.jpg')"/> > <mx:Button label="Salvar" id="btSalvar" click="save()" > icon="@Embed('icons/save12.jpg')"/> > <mx:Button label="Excluir" id="btExcluir" click="remove()" > icon="@Embed('icons/delete_lixo_10.jpeg')"/> > </mx:ControlBar> > > </mx:Panel> > > <mx:CurrencyFormatter id="moneyFormatter" precision="2" > rounding="none" > decimalSeparatorTo="," thousandsSeparatorTo="." > useThousandsSeparator="true" useNegativeSign="true" > currencySymbol="$ " > alignSymbol="left"/> > > <mx:DateFormatter id="dateFormatter" formatString="DD/MM/YYYY" /> > > <mx:RemoteObject id="pagamentoService" showBusyCursor="true" > fault="onFault(event)" destination="pagamentoService"> > <mx:method name="save" result="onResultSave(event)" > fault="onFault(event)"/> > <mx:method name="remove" result="onResultRemove(event)" > fault="onFault(event)"/> > <mx:method name="getList" result="onResultGetList(event)" > fault="onFault(event)"/> > <mx:method name="getListUsuarios" > result="onResultGetListUsuarios(event)" fault="onFault(event)"/> > <mx:method name="aviso" result="onResultGetList(event)" > fault="onFault(event)"/> > </mx:RemoteObject> > > <mx:Script> > <![CDATA[ > import > com.digows.artigos.JavaFlex.view.entity.Usuario; > import > com.digows.artigos.JavaFlex.view.entity.Status; > import > com.digows.artigos.JavaFlex.view.entity.Pagamento; > import > com.digows.artigos.JavaFlex.view.entity.Pagamento; > import mx.collections.ArrayCollection; > import mx.rpc.events.ResultEvent; > import mx.rpc.events.FaultEvent; > import mx.controls.Alert; > import mx.utils.ObjectUtil; > > [Bindable] > private var listPagamentos:ArrayCollection; > [Bindable] > private var listUsuarios:ArrayCollection; > > private var pagamento:Pagamento; > > private var usuario:Usuario; > > public function save():void > { > > //Alert.show(combo_usuarios.selectedItem.data.toString()); > this.pagamento = new Pagamento(); > this.pagamento.dataPagamento = > dtdataVencimento.selectedDate; > this.pagamento.dataVencimento = > dtdataPagamento.selectedDate; > this.pagamento.valorPagamento = > Number(valorPagamentoTxt.text); > this.pagamento.valorVencimento = > Number(valorVencimentoTxt.text); > this.pagamento.obs = "teste"; > // Pegar o usuario selecionado > this.pagamento.usuario = > combo_usuarios.selectedItem as Usuario; > //Chama o metodo Save do servico > "cargoService" > pagamentoService.save(pagamento); > } > > private function > getListUsuariosResultHandler(event:ResultEvent):void > { > listUsuarios = event.result as ArrayCollection; > combo_usuarios.dataProvider(listUsuarios); > } > > > //Função que será executada após a conclusão do > método save > public function onResultSave(event:ResultEvent):void > { > status = "Salvo com Sucesso! Ultima ID: > "+Pagamento(event.result).id; > getList(); > } > > public function remove():void > { > if (dgPagamento.selectedItem != null) { > pagamento = dgPagamento.selectedItem > as Pagamento; > pagamentoService.remove(pagamento); > } else { > Alert.show("Selecione um Item na > DataGrid"); > } > } > > //Função que será executada após a conclusão do > método remove > public function > onResultRemove(event:ResultEvent):void > { > status = "Excluido com Sucesso!"; > getList(); > } > > public function getList():void > { > pagamentoService.getList(); > > combo_usuarios.dataProvider(pagamentoService.getListUsuarios()); > > combo_usuarios.dataProvider(getListUsuarios() as ArrayCollection) > > } > > public function getListUsuarios():void > { > pagamentoService.getListUsuarios(); > } > > //Função que será executada após a conclusão do > método getList > public function > onResultGetList(event:ResultEvent):void > { > listPagamentos = event.result as > ArrayCollection; > } > > //Função que será executada após a conclusão do > método getList > public function > onResultGetListUsuarios(event:ResultEvent):void > { > listUsuarios = event.result as > ArrayCollection; > combo_usuarios.dataProvider(listUsuarios); > } > > public function setDefault():void > { > dtdataPagamento.text = ""; > dtdataVencimento.text = ""; > valorPagamentoTxt.text = ""; > valorVencimentoTxt.text = ""; > > listUsuarios = getListUsuarios() as > ArrayCollection; > combo_usuarios.dataProvider(listUsuarios); > } > > //Ocorreu uma falha ao chamar algum servico servico. > public function onFault(event:FaultEvent):void > { > Alert.show(event.fault.message); > } > > private function formatDate(item:Object, > column:DataGridColumn):String > { > return dateFormatter.format(item[column.dataField]); > } > > private function formatMoney(item:Object, > column:DataGridColumn):String > { > return > moneyFormatter.format(item[column.dataField]); > } > ]]> > </mx:Script> > </mx:TitleWindow> > > -- > Você recebeu esta mensagem porque está inscrito na lista "flexdev" > Para enviar uma mensagem, envie um e-mail para [email protected] > Para sair da lista, envie um email em branco para > [email protected] > Mais opções estão disponíveis em http://groups.google.com/group/flexdev > -- Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para [email protected] Para sair da lista, envie um email em branco para [email protected] Mais opções estão disponíveis em http://groups.google.com/group/flexdev
