4 Replies Latest reply on Dec 7, 2008 9:24 AM by Michael Borbor

    Gluing MXML databinding together

    Daniel Freeman Level 1
      I'm an experienced programmer, and AS3 developer. Occasionally, I try to acquire more MXML conjuring tricks. Right now I'm stuck on something trivial. (Easy to solve in ActionScript, but what's the MXML way?)

      I just want two DataGrids, so that one GataGrid just copies the values in the other. The problem I'm having is that values (output) method yields an array of objects, and the databind method seems to expect a simple array. So how do I glue them together without resorting to ActionScript? I want to link a DataGrid to a chart in the same way.
        • 1. Re: Gluing MXML databinding together
          Michael Borbor Level 4
          if you could post what's the structure of the array would be great.
          • 2. Re: Gluing MXML databinding together
            Daniel Freeman Level 1
            I mean like this, but instead of {mydata.value} write something that glues the DataGrids together.

            • 3. Re: Gluing MXML databinding together
              Level 7

              "Daniel Freeman" <webforumsuser@macromedia.com> wrote in message
              news:ghg2g2$o6e$1@forums.macromedia.com...
              > I'm an experienced programmer, and AS3 developer. Occasionally, I try to
              > acquire more MXML conjuring tricks. Right now I'm stuck on something
              > trivial.
              > (Easy to solve in ActionScript, but what's the MXML way?)
              >
              > I just want two DataGrids, so that one GataGrid just copies the values in
              > the
              > other. The problem I'm having is that values (output) method yields an
              > array
              > of objects, and the databind method seems to expect a simple array. So
              > how do
              > I glue them together without resorting to ActionScript? I want to link a
              > DataGrid to a chart in the same way.

              Actually, for data binding to work properly, you should be using one of the
              ListCollectionView classes, whether you're working in AS3 or MXML.
              Depending on what you're doing, either point both objects at the same
              Collection or make a new ListCollectionView that points at the same source
              and attach one object to one collection and the other object to the other
              collection.

              HTH;

              Amy


              • 4. Re: Gluing MXML databinding together
                Michael Borbor Level 4
                This will work.
                <mx:Script>
                <![CDATA[



                import mx.collections.ArrayCollection;
                var myMovies:ArrayCollection = new ArrayCollection([{Movie: 'Superman', stars: 3},{Movie: 'Batman', stars: 5}
                ,{Movie: 'Spiderman', stars: 4}]);

                ]]>
                </mx:Script>

                <mx:VBox x="41" y="25" height="100%">
                <mx:DataGrid width="98" editable="true" enabled="true" id="mydata" dataProvider="{this.myMovies}" height="115">
                <mx:columns>
                <mx:DataGridColumn headerText="values" dataField="Movie"/>
                <mx:DataGridColumn headerText="values" dataField="stars"/>
                </mx:columns>
                </mx:DataGrid>
                <mx:DataGrid width="98" editable="true" enabled="true" id="mycopy" dataProvider="{mydata.selectedItem.stars}" height="115">
                <mx:columns>
                <mx:DataGridColumn headerText="copy" dataField="values"/>
                </mx:columns>
                </mx:DataGrid>
                </mx:VBox>