O itemRenderer fica é outro contexto, portanto ele não tem acesso direto ao
componente pai.

Pra resolver, é só trocar
o taskList.getItemAt(dataGridTask.selectedIndex).nome por data.nome.
Assim você não precisa ter relação a nada de fora do itemRenderer.

A variável data é populada automagicamente no itemRenderer com o item atual
da coleção.

E para ter acesso ao componente pai (onde está o datagrid) pelo item
renderer, vc utiliza o parentDocument.

Ex.: parentDocument.dataGridTask, parentDocument.minhafuncao()

Recomendo colocar os itemRenderers em outro mxml para ficar mais limpo o seu
componente.

Abraço.

2010/5/31 Sérgio Fantin <[email protected]>

> Acontece exatamente a mesma coisa. O problema está em acessar meu
> dataGridTask.
> Quando eu coloco alguma string dentro do evento, funciona: new
> ProgramScheduleEvent("*alguma string...*"), mas quando eu coloco new
> ProgramScheduleEvent(taskList.getItemAt(dataGridTask.selectedIndex).nome) eu
> recebo erro de compilação.
> Depois da sugestão com Slider ficou assim:
>
> <mx:DataGrid id="dataGridTask" x="10" y="10" width="782.5" height="268"
> dataProvider="{taskList}">
>                 <mx:columns>
>                     <mx:DataGridColumn headerText="Descrição "
> dataField="description"/>
>                     <mx:DataGridColumn headerText="Tarefa Agendada"
> id="taskSchedule" dataField="taskGroupVO.description"/>
>                     <mx:DataGridColumn headerText="Cadastrado em "
> dataField="register" labelFunction="formatDate"/>
>                     <mx:DataGridColumn headerText="Editar "
> textAlign="center">
>                         <mx:itemRenderer>
>                             <mx:Component>
>                                 <mx:HBox horizontalAlign="center">
>                                     <mx:Script>
>
>                                         <![CDATA[
>                                             import
> br.com.sumus.coyote.program.events.ProgramScheduleEvent;
>
>                                             private function
> enviarValor(event:ProgramScheduleEvent):void {
>
> outerDocument.popupEditProgramSchedule.valor2 = event.valor;
>
> outerDocument.showEditProgramSchedule();
>                                             }
>                                             ]]>
>                                       </mx:Script>
>
>
>                                     <mx:Image id="documentImage"
> source="../images/document.gif" height="100%">
>                                         <mx:click>
>                                              <![CDATA[
>                                                  dispatchEvent(*new
> ProgramScheduleEvent(taskList.getItemAt(dataGridTask.selectedIndex).nome)*
> );
>                                              ]]>
>                                         </mx:click>
>                                     </mx:Image>
>                                   </mx:HBox>
>                             </mx:Component>
>                         </mx:itemRenderer>
>                     </mx:DataGridColumn>
> Alguém conhece alguma forma de acessar esse cara?
>
>
> 2010/5/31 Sérgio Fantin <[email protected]>
>
> Obrigado, Davidson!
>>
>>
>> 2010/5/31 デビデソヌ Davidson Silva <[email protected]>
>>
>>  Using a Slider control as a DataGrid column item renderer in Flex
>>>
>>> by Peter deHaan on May 9, 2008
>>>
>>> in DataGrid <http://blog.flexexamples.com/category/halo/datagrid/>,
>>> HSlider <http://blog.flexexamples.com/category/halo/hslider/>
>>>
>>> The following example shows how you can use an HSlider control as an item
>>> renderer in a Flex DataGrid control.
>>>
>>> Full code after the jump.
>>>
>>> View 
>>> MXML<http://blog.flexexamples.com/wp-content/uploads/DataGridColumn_itemRenderer_HSlider_test/bin/srcview/source/main.mxml.html>
>>>
>>> <?xml version="1.0" encoding="utf-8"?>
>>> <!-- 
>>> http://blog.flexexamples.com/2008/05/09/using-a-slider-control-as-a-datagrid-column-item-renderer-in-flex/
>>>  -->
>>>
>>>
>>>
>>> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>>>         layout="vertical"
>>>         verticalAlign="middle"
>>>         backgroundColor="white">
>>>
>>>
>>>
>>>     <mx:ArrayCollection id="arrColl">
>>>         <mx:source>
>>>             <mx:Array>
>>>                 <mx:Object label="Student A" score="85" />
>>>                 <mx:Object label="Student B" score="48" />
>>>
>>>
>>>
>>>                 <mx:Object label="Student C" score="71" />
>>>                 <mx:Object label="Student D" score="88" />
>>>                 <mx:Object label="Student E" score="24" />
>>>
>>>
>>>
>>>                 <mx:Object label="Student F" score="64" />
>>>                 <mx:Object label="Student G" score="76" />
>>>                 <mx:Object label="Student H" score="76" />
>>>
>>>
>>>
>>>                 <mx:Object label="Student I" score="93" />
>>>                 <mx:Object label="Student J" score="88" />
>>>                 <mx:Object label="Student K" score="48" />
>>>
>>>
>>>
>>>                 <mx:Object label="Student L" score="76" />
>>>             </mx:Array>
>>>         </mx:source>
>>>     </mx:ArrayCollection>
>>>
>>>     <mx:DataGrid id="dataGrid"
>>>
>>>
>>>
>>>             dataProvider="{arrColl}"
>>>             selectable="false"
>>>             rowCount="6"
>>>             width="500">
>>>         <mx:columns>
>>>             <mx:DataGridColumn dataField="label" />
>>>
>>>
>>>
>>>             <mx:DataGridColumn dataField="score" />
>>>             <mx:DataGridColumn dataField="score">
>>>                 <mx:itemRenderer>
>>>                     <mx:Component>
>>>
>>>
>>>
>>>                         <mx:HBox horizontalScrollPolicy="off"
>>>                                 verticalScrollPolicy="off">
>>>                             <mx:Script>
>>>                                 <![CDATA[
>>>
>>>
>>>
>>>                                     import mx.events.SliderEvent;
>>>
>>>                                     private function 
>>> slider_change(evt:SliderEvent):void {
>>>                                         data.score = evt.value;
>>>
>>>
>>>
>>>                                         outerDocument.arrColl.refresh();
>>>                                     }
>>>                                 ]]>
>>>                             </mx:Script>
>>>
>>>                             <mx:HSlider minimum="0"
>>>
>>>
>>>
>>>                                     maximum="100"
>>>                                     value="{data.score}"
>>>                                     liveDragging="true"
>>>                                     snapInterval="1"
>>>
>>>
>>>
>>>                                     width="100%"
>>>                                     change="slider_change(event);" />
>>>
>>>                         </mx:HBox>
>>>                     </mx:Component>
>>>
>>>
>>>
>>>                 </mx:itemRenderer>
>>>             </mx:DataGridColumn>
>>>         </mx:columns>
>>>     </mx:DataGrid>
>>>
>>> </mx:Application>
>>>
>>>
>>>
>>> Em 31 de maio de 2010 10:18, Sérgio Fantin 
>>> <[email protected]>escreveu:
>>>
>>>> Parece que tá fora o blog... tá conseguindo acessar?
>>>>
>>>> 2010/5/31 Victor Hugo <[email protected]>
>>>>
>>>> Sergio da uma olhada nesse link aqui
>>>>>
>>>>>
>>>>> http://blog.flexexamples.com/2008/05/09/using-a-slider-control-as-a-datagrid-column-item-renderer-in-flex/#more-623
>>>>>
>>>>> é basicamente oque tu tas tentando fazer.
>>>>>
>>>>> abraço!
>>>>>
>>>>> On 31 maio, 09:40, Sérgio Fantin <[email protected]> wrote:
>>>>> > Agora eu peguei dois erros:
>>>>> >
>>>>> > *1120: Access of undefined property taskList.
>>>>> >
>>>>> > 1120: Access of undefined property dataGridTask.
>>>>> > *
>>>>> > <mx:DataGrid id="dataGridTask" x="10" y="10" width="782.5"
>>>>> height="268"
>>>>> > dataProvider="{taskList}">
>>>>> >                 <mx:columns>
>>>>> >                     <mx:DataGridColumn headerText="Descrição "
>>>>> > dataField="description"/>
>>>>> >                     <mx:DataGridColumn headerText="Tarefa Agendada"
>>>>> > id="taskSchedule" dataField="taskGroupVO.description"/>
>>>>> >                     <mx:DataGridColumn headerText="Cadastrado em "
>>>>> > dataField="register" labelFunction="formatDate"/>
>>>>> >                     <mx:DataGridColumn headerText="Editar "
>>>>> > textAlign="center">
>>>>> >                         <mx:itemRenderer>
>>>>> >                             <mx:Component>
>>>>> >                                 <mx:HBox horizontalAlign="center">
>>>>> >                                     <mx:Image id="documentImage"
>>>>> > source="../images/document.gif" height="100%">
>>>>> >                                         <mx:click>
>>>>> >                                              <![CDATA[
>>>>> >                                                  import
>>>>> > br.com.sumus.coyote.program.events.ProgramScheduleEvent;
>>>>> >
>>>>> >                                                  dispatchEvent(new
>>>>> >
>>>>> ProgramScheduleEvent(taskList.getItemAt(dataGridTask.selectedIndex).nome));
>>>>> >                                              ]]>
>>>>> >                                         </mx:click>
>>>>> >                                     </mx:Image>
>>>>> >                                   </mx:HBox>
>>>>> >                             </mx:Component>
>>>>> >                         </mx:itemRenderer>
>>>>> > ...
>>>>> >
>>>>> > Quando eu tento usar o autocomplete no dataGridTask ele não funciona.
>>>>> De
>>>>> > fato ele não está sendo encontrado. :(
>>>>> >
>>>>> > 2010/5/31 Victor Hugo <[email protected]>
>>>>> >
>>>>> >
>>>>> >
>>>>> > > Tenta fazer assim.
>>>>> >
>>>>> > > taskList.getItemAt(datagridTask.selectedIndex).nome
>>>>> >
>>>>> > > pra ver oque dá
>>>>> >
>>>>> > > abraço
>>>>> >
>>>>> > > On 31 maio, 09:19, Sérgio Fantin <[email protected]>
>>>>> wrote:
>>>>> > > > Olá pessoal,
>>>>> >
>>>>> > > > preciso enviar o valor de um item do dataGrid. Quando eu envio
>>>>> uma String
>>>>> > > > literal(dispatchEvent(new ProgramScheduleEvent("literal"));) eu
>>>>> consigo,
>>>>> > > mas
>>>>> > > > quando eu coloco dataGridTask.selectedItem.nome eu recebo um erro
>>>>> de
>>>>> > > > compilação: *1120: Access of undefined property dataGridTask.*
>>>>> > > > Existe uma forma de acessar esse cara?
>>>>> >
>>>>> > > >             <mx:DataGrid id="dataGridTask" x="10" y="10"
>>>>> width="782.5"
>>>>> > > > height="268" dataProvider="{taskList}">
>>>>> > > >                 <mx:columns>
>>>>> > > >                     <mx:DataGridColumn headerText="Descrição "
>>>>> > > > dataField="description"/>
>>>>> > > >                     <mx:DataGridColumn headerText="Tarefa
>>>>> Agendada"
>>>>> > > > id="taskSchedule" dataField="taskGroupVO.description"/>
>>>>> > > >                     <mx:DataGridColumn headerText="Cadastrado em
>>>>> "
>>>>> > > > dataField="register" labelFunction="formatDate"/>
>>>>> > > >                     <mx:DataGridColumn headerText="Editar "
>>>>> > > > textAlign="center">
>>>>> > > >                         <mx:itemRenderer>
>>>>> > > >                             <mx:Component>
>>>>> > > >                                 <mx:HBox
>>>>> horizontalAlign="center">
>>>>> > > >                                     <mx:Image id="documentImage"
>>>>> > > > source="../images/document.gif" height="100%">
>>>>> > > >                                         <mx:click>
>>>>> > > >                                              <![CDATA[
>>>>> > > >                                                  import
>>>>> > > > br.com.sumus.coyote.program.events.ProgramScheduleEvent;
>>>>> > > >
>>>>>  *dispatchEvent(new
>>>>> > > > ProgramScheduleEvent(dataGridTask.selectedItem.nome));*
>>>>> > > >                                              ]]>
>>>>> > > >                                         </mx:click>
>>>>> > > >                                     </mx:Image>
>>>>> > > >                                   </mx:HBox>
>>>>> > > >                             </mx:Component>
>>>>> > > >                         </mx:itemRenderer>
>>>>> > > >                     </mx:DataGridColumn>
>>>>> >
>>>>> > > > Obrigado!
>>>>> >
>>>>> > > > --
>>>>> > > > Sérgio Fantinhttp://serjaum.wordpress.com
>>>>> >
>>>>> > > --
>>>>> > > 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 emhttp://
>>>>> groups.google.com/group/flexdev
>>>>> >
>>>>> > --
>>>>> > Sérgio Fantinhttp://serjaum.wordpress.com
>>>>>
>>>>> --
>>>>> 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
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Sérgio Fantin
>>>>
>>>> http://serjaum.wordpress.com
>>>>
>>>> --
>>>> 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
>>>
>>
>>
>>
>> --
>> Sérgio Fantin
>> http://serjaum.wordpress.com
>>
>
>
>
> --
> Sérgio Fantin
> http://serjaum.wordpress.com
>
> --
> 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
>



-- 
Fábio Goll
Gtalk/Msn: [email protected]
Twitter: @fabiogoll

-- 
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

Responder a