Avatar of mokatell
mokatell
 asked on

flex - list item renderer

dear experts ...
i have a question regarding the item renderer in flex for list ...


what is confusing me is the following ..

suppose i have component A has datagrid and this datagrid has item renderer ... if i wan to access any method in component A ... i am using parentDoucment.methodName ();

everything is fine till now ...

but i wanna know when i have item renderer for list and i want to access method in component A
i have ot use parentDocument.parentDocument.mehodName ...


so why i have to use twice the parentDocument when i have list ???
Apache Flex

Avatar of undefined
Last Comment
mokatell

8/22/2022 - Mon
zzynx

Can you show us the code of that item renderer in both cases?
mokatell

ASKER
this is the item renderer for list



<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx"
                        autoDrawBackground="true">
      
      <fx:Script>
            <![CDATA[
                  import classes.Methods;
                  
                  protected function image1_clickHandler(event:MouseEvent):void
                  {
                        parentDocument.parentDocument.commentsAttach(data);  
                        
                  }
                  
                  
                  
            ]]>
      </fx:Script>
      
      <s:VGroup width="100%" horizontalAlign="right" paddingBottom="10" paddingLeft="10" paddingTop="10" paddingRight="10"  >
                  <s:RichEditableText id="textDisplay" text="{data.comments}" width="{parentDocument.width-40}" />
                  <s:Label text="{data.whois+' '+data.dat}" color="red"/>      

            <s:HGroup>
                  <s:Image source="{Methods.attachIc}"  width="25" height="16" smooth="true" smoothingQuality="high" buttonMode="true" click="image1_clickHandler(event)"  />
<!--                  <s:Image source="{Methods.peopleIc}"  width="25" height="16" smooth="true" smoothingQuality="high" buttonMode="true" click="image2_clickHandler(event)"  />
-->            </s:HGroup>

      </s:VGroup>
      
      
</s:ItemRenderer>

                  



the Main Component

<mx:Accordion>      
      <mx:VBox label="Internal Correspondance" width="900"  paddingLeft="10" paddingTop="3" paddingRight="10" paddingBottom="3" >

                                    
                              <s:List width="100%"  alternatingItemColors="[0xD0D0D0,0xFFFFFF]"  dataProvider="{commentsArrayI}" id="historyComments" itemRenderer="renderers.commentsRenderer"/>
                              
                              
                              <s:HGroup verticalAlign="bottom" width="100%" >
                                    <s:TextArea width="755" height="50" id="zComments"/>

                                    <s:Button label="Add Comment" id="internalComments" click="button2_clickHandler(event)"/>
                              </s:HGroup>
                        
                        
                        </mx:VBox>

</mx:Accordion>      





as i told u if i have datagrid instead of list .. i would call parentDocument.method only one time but as u can see with list i have to do it twice ? !!!!!
ASKER CERTIFIED SOLUTION
zzynx

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
mokatell

ASKER
i did ... same senario for both ...
the script is copied as it is ....
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
zzynx

>> same senario for both ...
Meaning?
What class is parentDocument an instance of?

Can you post as attachments
- the code of your renderer
- the code where you use it with a List
- the code where you use it with a DataGrid
so I can run it myself?
zzynx

Well,... better late than never ;)
Thanx 4 axxepting
mokatell

ASKER
heheh my friend i was on vacation .. thats it .
sorry for being late
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.