This line:
teamMemberObj.selectedTeamMembers = dgTeamMemberName.selectedItems[j].name;
just puts the last name into the variable.  It needs to be an array, like:
var aSelectedMembers:Array;
teamMemberObj.aSelectedMembers[j] = dgTeamMemberName.selectedItems[j].name;

Then in initPopup:
dgTeamMemberAssignment2.dataProvider = teamMemberObj.aSelectedMembers;

Tracy

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of rgwilson26
Sent: Tuesday, May 16, 2006 1:27 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Passing data between two datagrids

I am working on an app (Flex 1.5) that passes data from the main
apps dataGrid and sends it to a popUp with another dataGrid. I have
some logic that will select all the data in the main apps datagrid
and send it to the popUp, but it only sends the last value in my
main apps dataGrid..

Does anyone have any suggestions of how to send all the values of my
main apps data grid to the popUps datagrid? I want the user to be
able to open the pop up with all the main app datagrid values so
they can add or delete them within the pop-up.

Below is some sample code.

Thanks,


**************************
       Main component
***************************
<mx:Script>
<![CDATA[
     
      public var selectedTeamMembers:String;
     
      public function addMember(){
            var teamMemberObj = new Object();
            var selectedIndices:Array = new Array
(dgTeamMemberName.length);
           
            //loop through and pull all names in the datagrid
            for(var i=0; i < dgTeamMemberName.length; i++) {
                  selectedIndices[i] = i;
            }
            dgTeamMemberName.selectedIndices = selectedIndices;
            for(var j=0; j <
dgTeamMemberName.selectedIndices.length; j++){
                  teamMemberObj.selectedTeamMembers =
dgTeamMemberName.selectedItems[j].name;
            }
            // Create a new pop-up with and add all team members
to pop-up datagrid
            var popup:Object  =
mx.managers.PopUpManager.createPopUp(_root, comp.popUpBox, true,
teamMemberObj);
            popup.addEventListener('teamMemberObject', this);
      }
           
     
]]>
</mx:Script>



<mx:DataGrid id="dgTeamMemberName">
<mx:columns>
   <mx:Array>
      <mx:DataGridColumn headerText="Name" columnName="name"/>
   </mx:Array>
</mx:columns>
</mx:DataGrid>

<mx:Button label="Add Team Member" click="addMember()"/>

**************************
       popUp component
***************************
<mx:Script>
<![CDATA[

      private function initPopUp(){
            if(selectedTeamMembers != ""){
                  dgTeamMemberAssignment2.addItem({name:
selectedTeamMembers});
            }
      }


]]>
</mx:Script>


<mx:DataGrid id="dgTeamMemberAssignment2" width="100%">
<mx:columns>
      <mx:Array>
            <mx:DataGridColumn headerText="Team Member(s)
assignment" columnName="name" />
      </mx:Array>
</mx:columns>
</mx:DataGrid>













--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links










--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to