If you call addItem(), updateItem(), etc, the PropertyChangedEvent is
dispatched by the IList implementor (ie, ArrayCollection).

But, if you have an IList of objects, and you do this:

var company : Company = companyList.getItemAt(3) as Company;
company.name = "New name";

then you'll only get the new data on screen if Company (or Company.name) is
marked [Bindable]

When you call the modifying methods on the dataprovider itself, then the
change is marked as happening on the IList (and it dispatches the
PropertyChangedEvent). But if you change the content of an object contained
within that list, nobody knows about it unless you add the [Bindable].
[Bindable] is a compile-time decorator that dispatches the events on your
behalf.

If I'm making things muddier rather than clearer with that, let me know ;-)

-J

On Mon, May 19, 2008 at 2:01 PM, gaurav1146 <[EMAIL PROTECTED]> wrote:

>   Hi,
> I have been using Bindable tag for data providers in datagrid, list
> etc. The doc states that this ensures that the destination datagrid
> would reflect the change when the dataprovider is changed. But I have
> observed that even if I do not use the Bindable tag the datagrid is
> still updated when the dataprovider changes. Here is a simple example:
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> /*Bindable tag not added. Flex Builder gives a warning when
> the variable is referenced in the datagrid but it still works.*/
> private var dp:ArrayCollection = new ArrayCollection([{index:1,
> word:"Test1"},{index:2, word:"Test2"}])
> public function changeDataProvider():void
> {
> var obj1:Object = new Object();
> obj1["index"] = 1;
> obj1["word"] = "Modified Test1";
> dp.setItemAt(obj1,0);
> var obj2:Object = new Object();
> obj2["index"] = 3;
> obj2["word"] = "Test3";
> dp.addItem(obj2);
> }
> ]]>
> </mx:Script>
> <mx:VBox>
> <mx:DataGrid dataProvider="{dp}"/>
> <mx:Button click="changeDataProvider()" label="Change data"/>
> </mx:VBox>
> </mx:Application>
>
> In the above example the datagrid changes on the button click. Please
> let me know if I am missing somthing.
>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to