What you want to use is the mx:Object instead of mx:Model.
This example dynamically adds a new object to the mx:Object "test" each time
the button is clicked.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*">
<mx:Script>
<![CDATA[
public var count:Number = 0;
public function addToModel():Void
{
var newRecord:Object = new Object();
newRecord.name = "Toby";
newRecord.sign = "Leo";
newRecord.birthYear = "1984";
test[ count++ ] = newRecord;
}
]]>
</mx:Script>
<mx:Object id="test"/>
<mx:Button label="Add" click="addToModel()"/>
<Inspect/>
</mx:Application>
HTH
Rob Rusher
RIA Consultant
Macromedia Certified Flex Instructor
e:[EMAIL PROTECTED] c:303.885.7044 im:robrusher
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of rgwilson26
Sent: Tuesday, January 24, 2006 11:38 AM
To: [email protected]
Subject: [flexcoders] Multiple values in a data model
I have an application I am working on where the user can input
information into various text input fields layed out in a HBOX. If
the user needs to add another person for the input they click on an
add event that dynamically creates another row.
My question is what is the best way to tie multiple entries to the
data model? If there is only a one line entry it would be no problem,
but what do you do when you want a data model to hold mulitple
entries from dynamically created input fields to be re-used
throughout the app or sent back to the database?
Any suggestions would be appreciated.
Thanks,
**********************************************
MY CODE
**********************************************
<?xml version="1.0" encoding="utf-8"?>
<mx:Application height="25"
xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Model id="basicInformationModel">
<EventDate>{txtRCAParticipants1.text}</EventDate>
<FaciltyDate>{txtTitle1.text}</FaciltyDate>
<SacActual>{cmbTeamRole1.selectedItem}</SacActual>
<SacPotential>{txtPhoneNumber1.text}</SacPotential>
</mx:Model>
<mx:Script>
<![CDATA[
var participantRowArray : Object = new Array() ;
var participantCounter : Number = 0 ;
//----------- RCA Participants --------------
private function addRCAParticipantsRow():Void
{
participantRowArray[participantCounter] =
Components.charterMemoParticipantsEntry
(participantsRowHolder.createChild
(Components.charterMemoParticipantsEntry,undefined, null ) );
participantCounter++;
}
]]>
</mx:Script>
<mx:HBox>
<mx:Label text="3.) RCA Participants" width="150"/>
<mx:Label text="Title" width="150"/>
<mx:Label text="Team Role" width="100"/>
<mx:Label text="Phone #" />
<mx:Button label="Add" width="60" click="addRCAParticipantsRow
();"/> <mx:Button label="Delete" width="60"
click="deleteRCAParticipantsRowRow();"/>
</mx:HBox>
<mx:HBox height="100%" width="100%">
<mx:TextInput id="txtRCAParticipants1" width="150" text="" />
<mx:TextInput id="txtTitle1" width="150" text="" />
<mx:ComboBox id="cmbTeamRole1" width="100">
<mx:dataProvider>
<mx:Array>
<mx:String></mx:String>
<mx:String>Leader</mx:String>
<mx:String>Member</mx:String>
<mx:String>Advisor</mx:String>
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
<mx:TextInput id="txtPhoneNumber1" width="150" text="" />
<mx:Spacer width="20" />
<mx:Button label="Delete" click="" />
</mx:HBox>
</mx:Application>
--
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
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/