2 Replies Latest reply on Sep 1, 2010 4:27 AM by IlyaG

    Looking for DataGrid sample

    IlyaG Level 1



      I have a function that gives me two arrays and I want to show them on data grid, those are my arrays:


      var names:Array;

      var LastNames:Array;


      And all what I want is to create a 3 columns datagrid with names, lastNames and full names.


      Can you help me with this one?

        • 1. Re: Looking for DataGrid sample
          ShardulSingh Level 3


          Pls find the solution for ur problem. Let me know if you have any issue.



          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
                      import mx.collections.ArrayCollection;
                      private var arrNames : Array = ['aName','bName','cName'];
                      private var arrLastNames : Array = ['aLastName','bLastName','cLastName'];
                      private var arrCollection : ArrayCollection = new ArrayCollection();
                      private function createColl() : void
                          for (var i : Number= 0; i< arrNames.length; i++)
                              var obj : Object = new Object();
                              obj.firstName = arrNames[i];
                              obj.lastName =  arrLastNames[i];
                              obj.fullName = obj.firstName + "  " + obj.lastName;
              <mx:DataGrid dataProvider="{arrCollection}" creationComplete="createColl()">
                  <mx:DataGridColumn width="150" dataField="firstName" headerText="First Name"/>
                  <mx:DataGridColumn width="150" dataField="lastName" headerText="Last Name"/>
                  <mx:DataGridColumn width="250" dataField="fullName" headerText="Full Name"/>







          with Regards,


          Shradul Singh Bartwal

          • 2. Re: Looking for DataGrid sample
            IlyaG Level 1

            Tnx, this is what I been looking for.