6 Replies Latest reply on Oct 15, 2009 8:34 AM by RosieGp

    add pop up

    RosieGp Level 1

      I have a portion in the form that I want to add if the user has multiple records...

      For example:

       

       

       

       

       

       

      <mx:Label x="10" y="611" text="Information" fontWeight="bold"/>

       

       

       

       

       

      <mx:ComboBox x="10" y="625" prompt="Make a Selection"></mx:ComboBox>

       

       

       

       

       

      <mx:Label x="10" y="645" text="Part A" fontWeight="bold" >

       

       

       

       

       

      <mx:RichTextEditor x="10" y="663" title="Record A" height="249" width="454">

       

       

       

       

       

      </mx:RichTextEditor>

       

       

       

       

       

      <mx:RichTextEditor x="472" y="663" title="Record B" height="249" width="518">

       

       

       

       

       

      </mx:RichTextEditor>

      <mx:Label x="10" y="645" text="Part B" fontWeight="bold" />

       

       

      <mx:Button

       

      x="878" y="625" label="Add New Record"/>

      So if the user wants to add a new record... the user can hit Add New Record Button and everything after the first Label is re-generated...

      How can i do that?

      Any help is appreciated...

        • 1. Re: add pop up
          Gregory Lafrance Level 6

          If this post answered your question or helped, please mark it as such.

           

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="addRecord();" width="100%" height="100%">
            <mx:Script>
              <![CDATA[
                import mx.controls.*;

                private function addRecord():void{
                  var vb:VBox = new VBox();
                  vb.setStyle("backgroundColor", "0xFFFFFF");
                  var infoLbl:Label = new Label();
                  infoLbl.text="Information"
                  infoLbl.setStyle("fontWeight", "bold");
                  vb.addChild(infoLbl);
                  var selectCbx:ComboBox = new ComboBox();
                  selectCbx.prompt = "Make a Selection";
                  vb.addChild(selectCbx);
                  var partA_Lbl:Label = new Label();
                  partA_Lbl.text = "Part A";
                  partA_Lbl.setStyle("fontWeight", "bold");
                  vb.addChild(partA_Lbl);
                  var recordA_Rte:RichTextEditor = new RichTextEditor();
                  recordA_Rte.title="Record A"
                  recordA_Rte.height=249;
                  recordA_Rte.width=454;
                  vb.addChild(recordA_Rte);
                  var recordB_Rte:RichTextEditor = new RichTextEditor();
                  recordB_Rte.title="Record B"
                  recordB_Rte.height=249;
                  recordB_Rte.width=518;
                  vb.addChild(recordB_Rte);
                  var partB_Lbl:Label = new Label();
                  partB_Lbl.text = "Part B";
                  partB_Lbl.setStyle("fontWeight", "bold");
                  vb.addChild(partB_Lbl);
                  var hr:HRule = new HRule();
                  hr.setStyle("strokeWidth", 2);
                  hr.setStyle("strokeThickness", 2);
                  hr.percentWidth = infoVB.width;
                  infoVB.addChildAt(hr, 0);
                  infoVB.addChildAt(vb, 0);
                }     
              ]]>
            </mx:Script>
            <mx:Button x="878" y="625" label="Add New Record" click="addRecord();"/>
            <mx:VBox id="infoVB" verticalGap="15" horizontalAlign="center"/>
          </mx:Application>

          • 2. Re: add pop up
            RosieGp Level 1

            How do I get data in the combobox ?
            For example selectCbx.dataprovider="{Data}" this generate {Data} when I click the combobox....

            • 3. Re: add pop up
              Gregory Lafrance Level 6

              Actually, in the code I provided the ComboBox is not assigned a dataProvider, so you need to figure out how you will do that. So a question I might ask is, when the user clicks the "Add New Record" button, where will the data to assign as the new ComboBox dataProvider come from?

               

              After that is solved, then if the user has added several records, and they change the selected item for one of the comboboxes, if you have assigned a change handler for the comboboxes, you can access the ComboBox(event.currentTarget).dataProvider to the data for that ComboBox whose value was changed.

              • 4. Re: add pop up
                RosieGp Level 1

                for the combobox the data is coming from Sql Database: hence the query

                my NEWRECORD.cfc has

                Select distinct RecordHeaders

                From RecordsDB

                so I have it as:

                NEWRECORD.mxml

                [Bindable] public var rhdata:ArrayCollection;

                private function resultNR(event:ResultEvent):Void{

                     rhdata=ArrayCollection(event.result);

                }

                <mx:ComboBox promt="Make a selection" dataProvider=''{rhdata}"/>

                Ofcourse there is a RemoteObject Connection to the ColdFusion server...

                This is what I have, there is no current target that I have....

                 

                • 5. Re: add pop up
                  Gregory Lafrance Level 6

                  I don't see the connection between the DB call and the ComboBoxes. You have to make this more clear for me to be able to comment.

                  • 6. Re: add pop up
                    RosieGp Level 1

                    In cfc I have the following:

                    NEWRECORD.cfc

                    <cfquery>

                    Select distinct RecordHeaders

                    From RecordsDB

                    </cfquery>

                    In mxml component:

                    NEWRECORD.mxml

                    [Bindable] public var rhdata:ArrayCollection;

                    private function resultNR(event:ResultEvent):Void{

                        rhdata=ArrayCollection(event.result);

                    }

                     

                    Here is the connection string:

                     

                     

                    <mx:RemoteObject

                     

                     

                    id="cf" destination="ColdFusion" source="cfc.NR">

                     

                     

                    <mx:method name="getNR" result="resultNR(event)" fault="Alert.show(event.fault.message)"/>

                     

                     

                    </mx:RemoteObject>

                     

                    <mx:ComboBox promt="Make a selection" dataProvider=''{rhdata}"/>