Dominique's approach is the correct one.

 

The Flex framework calls the set data() method on every renderer anytime
the underlying data changes.  This is because renderers are recycled.

 

So your renderer always has a reference to the dataProvider item that is
behind it.  Use that reference to update the item.

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of mark goldin
Sent: Friday, December 21, 2007 1:14 PM
To: flexcoders@yahoogroups.com
Subject: Re: [flexcoders] ComboBox ItemRenderer

 

No, that's not what I meant. I mean without using any ids, names, and
etc.

Something like other environments have: parent. 

Why can't I after I got a reference to an itemRenderer simply go up on
an object chain to get to DG and then talk to its dataProvider:

itemRenderer.parent.parent.gd.dataProvider

updating it with a new data from an itemRenderer? am I completely off
here?

Dominique Bessette - Halsema <[EMAIL PROTECTED]> wrote:

        you can talk to anything in your parentApplication by doing

         

        parentApplication.<whatever id name you gave the dataprovider>

         

        the variable parentApplication is a set flex variable that get's
all the data in the main app.

         

         

         

         

         

        
        
         

        On 12/21/07, mark goldin <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

        Aha, I see. Let me make sure I understand. 

        ownerData is defined in set method. That means it's set as many
times as many rows are in the DG, right? But why can't I talk directly
to the dataProvider of my DG? Or using a private var is the direct way? 

        
        
        Dominique Bessette - Halsema <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

        

                ownerdata is a variable that is set to the DG's row
data.

                 

                ownerData = value as XML;

                 

                get's the row data.  sorry i should have commented it
more

                
                
                 

                On 12/21/07, mark goldin <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

                Not sure I understand about ownerData. Is it a hard
coded dataProvider name for DG? I am working on a generic solution, I
can't use hard coded names. Sorry, if I am misunderstanding your
solution. 

                
                
                Dominique Bessette - Halsema <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

                Here is the code for the itemRenderer for a combobox i
made.  The dataProvider is xml.

                 

                 

                <?xml version="1.0" encoding="utf-8"?>
                <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
                 rowCount="2" labelField="@name"
dataProvider="{weemcStatus}" change="onSelectionChange(event)"> 
                     <mx:Script>
                        <![CDATA[
                            import mx.events.ListEvent;
                            import
mx.controls.dataGridClasses.DataGridListData;
                            import mx.collections.XMLListCollection;
                            
                            private var ownerData:XML;
                            
                            //binds the xml row data to the combobox and
appends the weemcStatus
                            override public function set
data(value:Object):void 
                            {
                                if(value){                  
                                    ownerData = value as XML; 
                                    if(ownerData.weemcStatus.toString()
== "" || ownerData.weemcStatus.toString () == null){
                                     var item:XML =
<weemcStatus>WILCO</weemcStatus>;
        
ownerData.appendChild(item.toXMLString());                 
                                    }
                                }      
                            }
                            
                            override public function get data():Object
                            {
                                return ownerData;
                            }
                            
                            override public function setFocus():void 
                            {
                                super.setFocus();
                                
                                open(); 
                            }
                            
                            //get's the new status and changes the xml
status value
                            private function
onSelectionChange(e:ListEvent):void 
                            {
                                if(selectedItem && ownerData){

                                    var col:DataGridListData =
DataGridListData(listData);
                                    var sname:String =
selectedItem.toString ();
                                    if(ownerData.weemcStatus.toString()
!= "" || ownerData.weemcStatus.toString() != null){
                                     ownerData.weemcStatus = sname;

                                    } 
                                    else{
                                     var item:XML =
<weemcStatus>{sname}</weemcStatus>; 
        
ownerData.appendChild(item.toXMLString()); 
                                    }  
                                } 
                            }
                            
                            
                            private var xmlStatus:XML =
                                <weemc> 
                                    <status>WILCO</status>
                                    <status>CANTCO</status>  
                                </weemc>;
                            
                            [Bindable]
                            private var weemcStatus:Array = (new
XMLListCollection( xmlStatus.status)).toArray();

                        ]]>
                    </mx:Script> 
                </mx:ComboBox>

                 

                On 12/20/07, mark goldin <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

                I am using a Combobox as an itemRenderer for one of
columns in a DG. I have managed to intercept "change" event of the
combobox. But what do I do to store new value from Combo into DG's
dataProvider for the following data save to the server? 

                What is an actual design pattern for that?

                 

                Thanks much for help.

                 

                 

                 

        
        
        

         

 

 

Reply via email to