1 Reply Latest reply on Aug 25, 2006 10:04 AM by deepa subramaniam (adobe)

    Dynamically adding/removing rows from a list bound to a XML data source?

    allnighter
      Hi,

      I have a list that is bound to a XML data provider. I want to be able to add new nodes in the XML provider and have that automatically reflected in the list. The problem is that XML data type is a native type that does not implement the IEventDispatcher interface and thus is incapable of transmitting its events to the listeners. I tried <mx:Model> element instead as that has Object Proxies inside it and can brroadcast events to listeners but I don't know how to get that to work?

      It it even possible to do this with XML based data providers or should I convert my data from XML to ArrayCollection before trying this?

      Thanks very much.

        • 1. Re: Dynamically adding/removing rows from a list bound to a XML data source?
          deepa subramaniam (adobe) Level 2
          Take your XML and create an XMLListCollection out of it (mx.collections.XMLListCollection). Once you bind your List control to an XMLListCollection, changes made to your data (through the XMLListCollection API) will be automatically picked up by the control. Remember to make your changes through the XMLListCollection API instead of to the underlying XML object. If you do make changes directly to the underlying XML object you'll need to inform the view that the change was made via the itemUpdated() method.

          There should be some examples of this in the docs under collections and binding UI controls to collections.

          HTH -
          deepa