Nesse caso teria q fazer alguma alteracao no mxml? 2009/10/12 Marcelo Caser <marceloca...@gmail.com>
> > amigo, > > vamos trabalhar com eventos para deixar as coisas mais simples. > > Faça o seguinte: > > private function init():void { > getCursos(); > } > > mude para: > > private function init():void { > // aqui definimos qual metodo sera disparado quando o evento que > estamos "escutando" for chamado na aplicacao. > addEventListener("getCursos", getCursos); > } > > > public function getCursos():void { > Alert.show("getCursos()"); > cursoService.getCursos(true); > } > > mude para: > > public function getCursos(event:Event):void { > cursoService.getCursos(true); > } > > private function excluir():void { > if (idxSelected > -1 && idxSelected <= listCursos.length - 1 && > cursoSelected != null) { > cursoService.excluiCurso(cursoSelected); > } else { > Alert.show("Selecione um Curso para excluir."); > } > } > > mude para: > > private function excluir():void { > if (idxSelected > -1 && idxSelected <= listCursos.length - 1 && > cursoSelected != null) { > cursoService.excluiCurso(cursoSelected); > //dispara o evento > dispatchEvent(new Event('getCursos', true)) > } else { > Alert.show("Selecione um Curso para excluir."); > } > } > > > > Em 12/10/09, RafaelViana<rfl.vi...@gmail.com> escreveu: > > > > *O mais curioso é que você falou que quando abre a tela novamente a > > lista atualiza (então o carregamento da lista está ok).Quando abre a > > tela chama o init que tem apenas o método getCursos. > > > > *E você chama esse método getCursos no result do excluir. > > > > *Lista está como bindable. > > > > Deve ser algum detalhe que está passando despercebido, se quiser mande > > o projeto para meu email que posso dar uma olhada. > > > > > > On 12 out, 11:26, Leonardo Ribeiro <leojribe...@gmail.com> wrote: > >> <mx:DataGrid x="10" y="10" width="419" height="286" id="dgCursos" > >> dataProvider="{listCursos}" > >> itemClick="dgCursoItemClick(event);" > >> dataChange="getCursos();"> > >> <mx:columns> > >> <mx:DataGridColumn headerText="Código" width="50" > >> dataField="codigo"/> > >> <mx:DataGridColumn headerText="Nome" width="100" > >> dataField="nome"/> > >> </mx:columns> > >> </mx:DataGrid> > >> > >> Nao adiantou nada ainda Marcelo. > >> O curioso é q do BD exclui correto e se saio e entro na tela de novo ele > >> carrega certo. > >> > >> No meu primeiro post eu coloquei todo o mxml e o as > >> > >> Qualquer ajuda é bem vinda > >> > >> 2009/10/11 Marcelo Caser <marceloca...@gmail.com> > >> > >> > >> > >> > >> > >> > coloque seu metodo de getCursos() na propriedade change do datagrid > >> > >> > 2009/10/11 Leonardo Ribeiro <leojribe...@gmail.com> > >> > >> >> Foi o q fiz (conforme primeira postagem) > >> > >> >> public function onResultExcluir(event: ResultEvent):void { > >> >> // listCursos.removeItemAt(idxSelected); > >> >> // idxSelected = -1; > >> >> // cursoSelected = null; > >> >> Alert.show("Curso excluído."); > >> >> getCursos(); > >> >> } > >> > >> >> 2009/10/11 Marcelo Caser <marceloca...@gmail.com> > >> > >> >> chame seu metodo de listagem novamente, apos excluir! > >> > >> >>> 2009/10/11 Leonardo Ribeiro <leojribe...@gmail.com> > >> > >> >>> Srs, > >> > >> >>>> Fiz uma listagem simples com um DataGrid e uns botoes (inserir, > >> >>>> alterar, > >> >>>> excluir) no momento estou testando apenas o Excluir. > >> >>>> A exclusao funciona perfeitamente (no banco) porém o datagrid nao > >> >>>> atualiza (continua com todos os registros de antes da exclusao). > >> >>>> Abaixo segue o mxml e o as. > >> > >> >>>> <?xml version="1.0" encoding="utf-8"?> > >> >>>> <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" > >> >>>> layout="absolute" width="576" height="346" title="Cursos" > >> >>>> showCloseButton="true" creationComplete="init();" alpha="1.0"> > >> >>>> <mx:DataGrid x="10" y="10" width="419" height="286" > id="dgCursos" > >> >>>> dataProvider="{listCursos}" > >> >>>> itemClick="dgCursoItemClick(event);"> > >> >>>> <mx:columns> > >> >>>> <mx:DataGridColumn headerText="Código" width="50" > >> >>>> dataField="codigo"/> > >> >>>> <mx:DataGridColumn headerText="Nome" width="100" > >> >>>> dataField="nome"/> > >> >>>> </mx:columns> > >> >>>> </mx:DataGrid> > >> >>>> <mx:Button x="442" y="11" label="Novo" width="101" id="btnNovo" > >> >>>> click="novo();"/> > >> >>>> <mx:Button x="442" y="41" label="Alterar" width="101" > >> >>>> id="btnAlterar" click="alterar();"/> > >> >>>> <mx:Button x="442" y="71" label="Excluir" width="101" > >> >>>> id="btnExcluir" click="excluir();"/> > >> >>>> <mx:Button x="442" y="274" label="Fechar" width="101" > >> >>>> id="btnFechar" > >> >>>> click="fechar();"/> > >> > >> >>>> <mx:RemoteObject id="cursoService" showBusyCursor="true" > >> >>>> fault="onFault(event)" destination="cursoService"> > >> >>>> <mx:method name="getCursos" > result="onResultGetCursos(event)" > >> >>>> fault="onFault(event)"/> > >> >>>> <mx:method name="excluir" result="onResultExcluir(event)" > >> >>>> fault="onFault(event)"/> > >> >>>> </mx:RemoteObject> > >> > >> >>>> <mx:Script source="cursoLst.as"/> > >> > >> >>>> </mx:TitleWindow> > >> > >> >>>> AS > >> > >> >>>> [Bindable] > >> >>>> private var listCursos:ArrayCollection; > >> >>>> private var cursoSelected:Curso; > >> >>>> private var idxSelected:int = -1; > >> > >> >>>> private function init():void { > >> >>>> getCursos(); > >> >>>> } > >> > >> >>>> private function novo():void { > >> > >> >>>> } > >> > >> >>>> private function alterar():void { > >> > >> >>>> } > >> > >> >>>> private function excluir():void { > >> >>>> if (idxSelected > -1 && idxSelected <= listCursos.length - 1 && > >> >>>> cursoSelected != null) { > >> >>>> cursoService.excluiCurso(cursoSelected); > >> >>>> } else { > >> >>>> Alert.show("Selecione um Curso para excluir."); > >> >>>> } > >> >>>> } > >> > >> >>>> public function onResultExcluir(event:ResultEvent):void { > >> >>>> // listCursos.removeItemAt(idxSelected); > >> >>>> // idxSelected = -1; > >> >>>> // cursoSelected = null; > >> >>>> Alert.show("Curso excluído."); > >> >>>> getCursos(); > >> >>>> } > >> > >> >>>> private function dgCursoItemClick(event:ListEvent):void { > >> >>>> idxSelected = event.rowIndex; > >> >>>> cursoSelected = listCursos.getItemAt(idxSelected) as Curso; > >> >>>> } > >> > >> >>>> private function fechar():void { > >> >>>> PopUpManager.removePopUp(this); > >> >>>> } > >> > >> >>>> public function getCursos():void { > >> >>>> Alert.show("getCursos()"); > >> >>>> cursoService.getCursos(true); > >> >>>> } > >> > >> >>>> public function onResultGetCursos(event:ResultEvent):void { > >> >>>> Alert.show("Pegou Cursos."); > >> >>>> listCursos = event.result as ArrayCollection; > >> >>>> } > >> > >> >>>> public function onFault(event:FaultEvent):void { > >> >>>> Alert.show(event.fault.message); > >> >>>> } > >> > >> >>>> O fonte ta beeem simples, apos excluir mando pegar os cursos de > novo > >> >>>> e a > >> >>>> listCursos esta como dataProvider do DataGrid. > >> >>>> Alguem sabe o que estou fazendo de errado? > >> > >> >>>> -- > >> >>>> []'s > >> >>>> Leonardo > >> > >> >>>> Linux User #488650 > >> >>>> Ubuntu User #27045 > >> >>>> Mais sobre o Ubuntu em português:http://www.ubuntu-br.org/comece > >> > >> >> -- > >> >> []'s > >> >> Leonardo > >> > >> >> Linux User #488650 > >> >> Ubuntu User #27045 > >> >> Mais sobre o Ubuntu em português:http://www.ubuntu-br.org/comece > >> > >> -- > >> []'s > >> Leonardo > >> > >> Linux User #488650 > >> Ubuntu User #27045 > >> Mais sobre o Ubuntu em português:http://www.ubuntu-br.org/comece > > > > > > > > > -- []'s Leonardo Linux User #488650 Ubuntu User #27045 Mais sobre o Ubuntu em português: http://www.ubuntu-br.org/comece --~--~---------~--~----~------------~-------~--~----~ Você recebeu esta mensagem porque está inscrito na lista "flexdev" Para enviar uma mensagem, envie um e-mail para flexdev@googlegroups.com Para sair da lista, envie um email em branco para flexdev-unsubscr...@googlegroups.com Mais opções estão disponíveis em http://groups.google.com/group/flexdev -~----------~----~----~----~------~----~------~--~---