I think I understand why. The dataprovider in the example is the actual XML 
List. I was wrapping the XML List in an XML List Collection so it wasn't 
updating the underlying dataprovider.

--- In [email protected], "Tracy Spratt" <tr...@...> wrote:
>
> No, you maybe had something else going on.  Here is an example based on the
> example in the docs.
> 
>  
> 
> <?xml version="1.0"?>
> 
> <!-Editable DataGrid control example. -->
> 
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; >
> 
>  
> 
>   <mx:Panel title="DataGrid Control Example" height="100%" width="100%" 
> 
>     paddingTop="10" paddingLeft="10" paddingRight="10">
> 
>  
> 
>     <mx:Label width="100%" color="blue"
> 
>       text="Select a row in the DataGrid control."/>
> 
>  
> 
>     <mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" 
> 
>       dataProvider="{employees}" editable="true">
> 
>       <mx:columns>
> 
>         <mx:DataGridColumn dataField="name" headerText="Name"
> editable="true"/>
> 
>         <mx:DataGridColumn dataField="phone" headerText="Phone"
> editable="true"/>
> 
>         <mx:DataGridColumn dataField="email" headerText="Email"
> editable="true"/>
> 
>       </mx:columns>
> 
>     </mx:DataGrid>
> 
>  
> 
>     <mx:Button label="Show DataProvider" click="txtDP.text =
> dg.dataProvider.toXMLString()" />
> 
>     <mx:Text id="txtDP" width="100%" height="100%" />
> 
>   </mx:Panel>
> 
>   
> 
>   <mx:XMLList id="employees">
> 
>     <employee>
> 
>       <name>Christina Coenraets</name>
> 
>       <phone>555-219-2270</phone>
> 
>       <email>ccoenra...@...</email>
> 
>       <active>true</active>
> 
>     </employee>
> 
>     <employee>
> 
>       <name>Joanne Wall</name>
> 
>       <phone>555-219-2012</phone>
> 
>       <email>jw...@...</email>
> 
>       <active>true</active>
> 
>     </employee>
> 
>     <employee>
> 
>       <name>Maurice Smith</name>
> 
>       <phone>555-219-2012</phone>
> 
>       <email>maur...@...</email>
> 
>       <active>false</active>
> 
>     </employee>
> 
>     <employee>
> 
>       <name>Mary Jones</name>
> 
>       <phone>555-219-2000</phone>
> 
>       <email>mjo...@...</email>
> 
>       <active>true</active>
> 
>     </employee>
> 
>   </mx:XMLList>  
> 
> </mx:Application>   
> 
>  
> 
>  
> 
> Tracy Spratt,
> 
> Lariat Services, development services available
> 
>   _____  
> 
> From: [email protected] [mailto:[email protected]] On
> Behalf Of valdhor
> Sent: Friday, June 12, 2009 11:57 AM
> To: [email protected]
> Subject: [flexcoders] Re: ArrayCollection and Datagrid Binding and
> DataProvider Question
> 
>  
> 
> 
> 
> 
> 
> 
> I didn't know this.
> 
> When I tried it, it didn't update the dataprovider. Is there anything
> special that needs to happen.
> 
> --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
> "Tracy Spratt" <tracy@> wrote:
> >
> > Data binding in general is not two-way, but an editable datagrid is a
> > special case. It will update the dataProvider items automatically.
> > 
> > 
> > 
> > Tracy Spratt,
> > 
> > Lariat Services, development services available
> > 
> > _____ 
> > 
> > From: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> [mailto:flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com]
> On
> > Behalf Of valdhor
> > Sent: Friday, June 12, 2009 9:42 AM
> > To: flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com
> > Subject: [flexcoders] Re: ArrayCollection and Datagrid Binding and
> > DataProvider Question
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Basically, no. The datagrid is like a window into your dataprovider.
> > 
> > If you need to modify your dataprovider you need to listem for the
> > itemEditEnd event, grab the data that was modified and update the
> underlying
> > dataprovider.
> > 
> > The data binding will note that the dataprovider has changed and will
> update
> > the datagrid on the next redraw.
> > 
> > What data binding does is add an event dispatcher to the variable you have
> > defined as bindable. When the variable changes an event is generated to
> let
> > any component that is bound to that variable know that the variable has
> > changed and update itself with the new data.
> > 
> > Now, As I understand it (And I could be wrong) Flex 4 (Gumbo) does do full
> > two way data binding. I have not read up on what or how it does this but
> it
> > sounds interesting.
> > 
> > HTH
> > 
> > Steve
> > 
> > --- In flexcod...@yahoogro <mailto:flexcoders%40yahoogroups.com> ups.com,
> > Angelo Anolin <angelo_anolin@> wrote:
> > >
> > > Good day.
> > > 
> > > Learning Flex here for the past two (like three actually) weeks. Using
> > only mxml compiler.
> > > 
> > > I have a question with regards to the above subject:
> > > 
> > > Assuming I declared an ArrayCollection as follows:
> > > 
> > > [Bindable] private var _arrItems:ArrayCollection = new
> > ArrayCollection([{"itemNo":"1", "testItem":"Angelo"}, {"itemNo":"2",
> > "testItem":"Dinah"}]);
> > > 
> > > This array I am binding to a datagrid as follows:
> > > 
> > > <mx:DataGrid id="dgOutwardList" 
> > > dataProvider="{_arrItems}" 
> > > useRollOver="false" 
> > > height="450"
> > > width="100%" 
> > > verticalScrollPolicy="auto" 
> > > sortableColumns="false" 
> > > draggableColumns="false" 
> > > resizableColumns="false">
> > > <mx:columns>
> > > <mx:DataGridColumn headerText="" dataField="itemNo" width="20"/>
> > > <mx:DataGridColumn headerText="Name of Passengers" dataField="testItem"
> > width="200">
> > > <mx:itemRenderer>
> > > <mx:Component>
> > > <mx:TextInput width="100%" />
> > > </mx:Component>
> > > </mx:itemRenderer>
> > > </mx:DataGridColumn>
> > > 
> > > </mx:columns>
> > > </mx:DataGrid>
> > > 
> > > No problem initially, as the itemNo and the testItem values are
> displayed
> > properly on the datagrid.
> > > 
> > > Now for example, if I modified my first row which contains itemNo:1 and
> > testItem:Angelo, where I changed Angelo to Mickey, will the dataprovider
> > reflect the change in the said row?
> > > How do I make so that the changes in the datagrid be reflected into the
> > ArrayCollection? such that when I changed the testItem data for the first
> > row and access the item, via:
> > > 
> > > _arrItems.getItemAt(arrLength -1).itemNo
> > > _arrItems.getItemAt(arrLength -1).testItem
> > > 
> > > The result would be "1" and "Mickey" respectively?
> > > 
> > > I am a bit puzzled on how databinding actually works in Flex. Is it like
> a
> > two-way live update (such that when you modify the value in the datagrid,
> it
> > is reflected back to the arraycollection)?
> > > 
> > > Would love to hear your inputs.
> > > 
> > > Thanks and regards,
> > > Angelo
> > >
> >
>


Reply via email to