public function handleDataChanged(event:ListEvent):void 
  { 
  data.person = selectedItem.data; 
  trace(listData.owner.dataProvider);
    
} 
  trace gives the compiler error.

Alex Harui <[EMAIL PROTECTED]> wrote:
              Let’s say you had:
  
  var dp:XML = <top>
              <item />
              <item />
  </top>
  
  If you have:
  
  <mx:DataGrid dataProvider=”{dp.item}” />
  
  From a ComboBox renderer, .owner.dataProvider is an XMLListCollection, 
.owner.dataProvider.source === dp.items
  
      
---------------------------------
  
  From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of mark 
goldin
Sent: Saturday, December 22, 2007 3:46 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] ComboBox ItemRenderer

  
          Not sure I understand. I am using Flex 3 Beta.

    

    I am trying to get DG's complete XML in Combo's change event but can't find 
a way of doing this.

Alex Harui <[EMAIL PROTECTED]> wrote:

            In one of the 2.0.1 hotfixes, we wired up .owner to the DG so you 
don’t have to implement IDropInLIR anymore.

    If you pass in XML to the DG’s dataProvider propert! y, it will be wrapped 
in an XMLLIstCollection when you read it back.

      
---------------------------------
  
    From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
mark goldin
Sent: Saturday, December 22, 2007 9:46 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] ComboBox ItemRenderer


          Yes, 

      listData.owner does point to the DG in my change event handler. But when 
I 

      trace(listData.owner.dataProvider) expecting to see an XML data (and 
that's what I want) I get a compiling error, if I say proceed trace will show 
DG but not its data. What am I doing wrong?


      Tracy Spratt <[EMAIL PROTECTED]> wrote:


              If a renderer implements the IDropInListItemRenderer interface, 
and most controls, like ComboBox do, then it can access listData() as 
Dominique’s code shows.


      Then, the listData.owner property does point to the DG.  Note the casting 
in Dominique’s example.


      Tracy


      
---------------------------------
  
      From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
mark goldin
Sent: Saturday, December 22, 2007 12:02 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] ComboBox ItemRenderer



            Is there anything available in set data that will point to the 
whole DG, not just the current row?

Alex Harui <[EMAIL PROTECTED]> wrote: 


                I would update the backing .data too., but the .owner property 
does point to the DG.



      
---------------------------------
  
        From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
Tracy Spratt
Sent: Friday, December 21, 2007 4:18 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] ComboBox ItemRenderer




                Do! minique’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



      
---------------------------------
  size=2 width="100%" align=center tabIndex=-1> 
        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 da! ta in the main app.




          

 




          On 12/21/07, mark goldin <[EMAIL PROTECTED]&g! t; 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] > 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] > wrote: 



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



          

Dominique Bessette - Halsema <[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 "
 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] > 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