2 Replies Latest reply on Dec 17, 2009 11:41 AM by ian-d-m

    How to get data from datagrid, Flex4

    ian-d-m

      I have read a web service to load my datagrid and have made some edits to it. What is the preferred way/format of accessing the updated data store. I have tried converting the object to XML but I seem to get a structure which has my data twice over, so I'm missing something obvious. I'm loading from ArrayList from an IIS web server in this case, which is built so easily from the wsdl. I want to send the data back to the service to do the Commit.

       

      Thanks

        • 1. Re: How to get data from datagrid, Flex4
          Flex harUI Adobe Employee

          How are you doing the conversion to XML?

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: How to get data from datagrid, Flex4
            ian-d-m Level 1

            He rerplies with embarrassed face....my hacking got me this far... (!)

             

                       protected function objectToXML(obj:Object):XML {
                            var qName:QName = new QName("root");
                            var xmlDocument:XMLDocument = new XMLDocument();
                            var simpleXMLEncoder:SimpleXMLEncoder = new SimpleXMLEncoder(xmlDocument);
                            var xmlNode:XMLNode = simpleXMLEncoder.encodeValue(obj, qName, xmlDocument);
                            var xml:XML = new XML(xmlDocument.toString());
                            return xml;
                        }
                           
                        protected function arrayCollectionToXML(ac:ArrayCollection):XML
                        {
                            var xml:XML = objectToXML(ac);
                            return xml;
                        }
                        protected function savegrid(event:MouseEvent):void
                        {
                            var xxx:XML = new XML();
                            xxx = arrayCollectionToXML(dataGrid.dataProvider as ArrayCollection);  

             

                           // I was trying to save the data here...

              
                        }