3 Replies Latest reply on Jan 25, 2010 3:39 AM by archemedia

    Displaying ObjectProxys in ArrayCollection in DataGrid


      Hi all,


      I'm getting a response from a HTTPService which I load into an ObjectProxy then add to an ArrayCollection.  Using the flex builder debugger I have verified that everything that pulls out the HTTPService result and loads the result properties into an ObjectProxy does work as well as the the 1 line that adds the ObjectProxy to the ArrayCollection, BUT I cannot seem to be able to display the ArrayCollection of ObjectProxys in a DataGrid.  I've set the ArrayCollection to be Bindable and I've set the ArrayCollection as the dataProvider of the DataGrid.  Does anybody know why my data in the ArrayCollection will not show up in the DataGrid?  Is there something incorrect I'm doing here?





        • 1. Re: Displaying ObjectProxys in ArrayCollection in DataGrid
          Flex harUI Adobe Employee

          As long as the DataGridColumn's dataField is a property in the ObjectProxy

          it should show something.

          • 2. Re: Displaying ObjectProxys in ArrayCollection in DataGrid
            DBrummett Level 1

            After doing some more debugging I found the reason why the Datagrid was not being populated, but it leads to another question.


            I found that the ArrayCollection is being populated with ObjectProxys, but after at some point after the event handler all of the ObjectProxys are getting destroyed for some reason.  At first I assumed it was because I was only making shallow copies of the HTTPService response objects so I added in a function to do a deep copy of all objects into a new ArrayCollection from the HTTPService response, but I'm still seeing the same behaviour of the objects getting destroyed at the end of the event handler for no apparent reason.  I've copied the code the makes the HTTPService request, and the event handler and the functions that do the deep copy, can anybody please help me here?  I have no idea why these objects are not persistent.


            public function queryMore(num : int) : void {

            var service:HTTPService = new HTTPService();



            service.addEventListener(ResultEvent.RESULT, this.queryMoreResult);

            var sendParam : ObjectProxy = new ObjectProxy();

            sendParam.user = "test_user";

            sendParam.pswd = "123qaz";

            sendParam.spec = "p_QueryMore_V2.ip.xml";

            sendParam.data = serviceSessionId + "|All_HDS_Pro_Tables";

            sendParam.action = "";

            sendParam.request = "inputMsg";

            sendParam.response = "outputMsg";

            sendParam.wait = "true";

            sendParam.log = "false";

            sendParam.num = num.toString();




            private function queryMoreResult(event : ResultEvent) : void {

            if (event.result == null) {

            Alert.show("There was a query error, please check your search terms and retry the search.");

            } else {

            if (event.result.PIEngineResponse.response != "END") {

            var temp : ObjectProxy;

            for each (temp in processDataset(event.result.PIEngineResponse.response.webRowSet)){






            } else {

            //summaryGrid.dataProvider = providerSummaryData;

            //Alert.show("Recieved all data.", "Success");







            private function processDataset(data : ObjectProxy) : ArrayCollection {

            var metadata : Array;


            //Get metadata from the webrowset

            metadata = buildMetaDataList(data);


            //Load webrowset data into XMLList

            return buildDataSet(data, metadata);




            private function buildMetaDataList(webRowSet : ObjectProxy) : Array {

            var colCount : int = webRowSet.metadata["column-count"];

            var data : Array = new Array(colCount);

            var i : int;


            for (i=0; i<colCount; i++) {

            data[i] = webRowSet.metadata["column-definition"][i]["column-name"];


            return data;




            private function buildDataSet(webRowSet : ObjectProxy, metadata : Array) : ArrayCollection {

            var i : int;

            var a : ObjectProxy;

            var b : ObjectProxy;

            var data : ArrayCollection = new ArrayCollection();



            for each (a in webRowSet.data.insertRow) {

            b = new ObjectProxy();


            for (i=0; i<metadata.length; i++) {

            b[metadata[i]] = a.columnValue[i];




            return data;





            • 3. Re: Displaying ObjectProxys in ArrayCollection in DataGrid
              archemedia Level 4

              It shouldn't be necessary to make deep copies of your result objects. There has to be something else going on here.

              If you're sure that the result property is an array of objects, just try to concat them with the source property of your ArrayCollection. After that, call the refresh method of the ArrayCollection. Make a screenshot of the result object expanded so I can see what's coming in.