Chamar função em datagrid FLEX

1 resposta
surfzera

Pessoal não estou conseguindo chamar minha função abrir(), em um imagem … qual o problema ?

//View

<mx:DataGrid id="dg" x="5" y="5" width="968" height="329" doubleClickEnabled="true" doubleClick="abrir()" change="selectedItems()" creationComplete="listar()">
					<mx:columns>
						<mx:DataGridColumn headerText="Os(s)">
							<mx:itemRenderer>
								<fx:Component>
									<mx:Image horizontalAlign="center" source="assets/img/lupa.png" height="16" width="16" click="abrir()" toolTip="Visualizar Os(s) do Projeto"/>	
								</fx:Component>
							</mx:itemRenderer>
						</mx:DataGridColumn> 
					</mx:columns>
				</mx:DataGrid>


<fx:Script source="../action/ProjetoAction.as"/>

//Função abrir localizada no ProjetoAction

public function abrir():void{
	if(dg.selectedIndex < 0)
		return;
	var a:OsView = new OsView();
	var id:int = dg.dataProvider[dg.selectedIndex].id;
	a.valorRecebido = id;
	PopUpManager.addPopUp(a,this.parent,false);
}

1 Resposta

surfzera

consegui fazendo assim nao sei se existe outra forma.

<mx:DataGridColumn headerText="Os(s)">
							<mx:itemRenderer>
								<fx:Component>
									<mx:Image horizontalAlign="center" source="assets/img/lupa.png" height="16" width="16" click="abrir()" toolTip="Visualizar Os(s) do Projeto">
										<fx:Script>
											<![CDATA[
												import br.com.sectioaurea.gestio.core.view.OsView;
												import mx.managers.PopUpManager;
												import mx.controls.DataGrid;
												
												public function abrir():void{
													var grid:DataGrid = DataGrid(outerDocument.dg);
													if(grid.selectedIndex < 0)
														return;
													var a:OsView = new OsView();
													var id:int = grid.dataProvider[grid.selectedIndex].id;
													a.valorRecebido = id;
													PopUpManager.addPopUp(a,this.parent,false);
												}
											]]>
										</fx:Script>
									</mx:Image>	
								</fx:Component>
							</mx:itemRenderer>
						</mx:DataGridColumn>
Criado 11 de agosto de 2010
Ultima resposta 11 de ago. de 2010
Respostas 1
Participantes 1