6 Replies Latest reply on Nov 12, 2010 5:31 PM by ParaicKW

    Can a ComboBox be used for Text Input ?

    ParaicKW

      Hi

       

      In Ms Access the combo box can be used for text input for creating new lines in the Database instead of just being limited to the lines already there in the drop down list. Is this possible with the combo box available in Flex 4. If it is I haven't being successful in getting it to work.

       

      Thanks for you help in advance

      ParaicKW

        • 1. Re: Can a ComboBox be used for Text Input ?
          JeffreyGong Level 1

          Spark ComboxBox can be used as TextInput in Flex 4.

           

          Jeffrey

          • 2. Re: Can a ComboBox be used for Text Input ?
            Jason Szeto Level 3

            When you type into the ComboBox's text input, this should update its selectedItem property. Can you be more specific in describing the problem you are experiencing? Also, code would help.

             

            - Jason

            • 3. Re: Can a ComboBox be used for Text Input ?
              ParaicKW Level 1

              I am using a Dataservices Commit method to write to the Database via a button on the screen

              When I type into the ComboBox's text input and click outside the combobox or on the commit button the application effectively freezes

              SituationService is a CRUD type servicePHP to MYSQL and it works with the Datagrid

              Here is the code -

              ParaicKW

               

              <?xml version="1.0" encoding="utf-8"?>
              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                             xmlns:s="library://ns.adobe.com/flex/spark"
                             xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:situationservice="services.situationservice.*">
                  <fx:Script>
                      <![CDATA[
                          import mx.controls.Alert;
                          import mx.events.FlexEvent;
                         
                          protected function Situation_creationCompleteHandler(event:FlexEvent):void
                          {
                              getAllTblsituationResult3.token = situationService.getAllTblsituation();
                          }
                         
                         
                          protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
                          {
                              getAllTblsituationResult.token = situationService.getAllTblsituation();
                          }

               

                          protected function button1_clickHandler(event:MouseEvent):void
                          {
                              situationService.commit();
                          }

               

                         
                          protected function vGroup_creationCompleteHandler(event:FlexEvent):void
                          {
                              getAllTblsituationResult2.token = situationService.getAllTblsituation();
                          }
                         
                      ]]>
                  </fx:Script>
                  <fx:Declarations>
                      <s:CallResponder id="updateSituationResult"/>
                      <situationservice:SituationService id="situationService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                      <s:CallResponder id="getAllSituationResult"/>
                      <s:CallResponder id="getAllTblsituationResult"/>
                      <s:CallResponder id="getAllTblsituationResult2"/>
                      <s:CallResponder id="getAllTblsituationResult3"/>
                      <!-- Place non-visual elements (e.g., services, value objects) here -->
                  </fx:Declarations>
                 
                  <mx:DataGrid x="96" y="167" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllTblsituationResult.lastResult}" editable="true" width="470" height="237">
                      <mx:columns>
                          <mx:DataGridColumn headerText="ID2" dataField="ID2"/>
                          <mx:DataGridColumn headerText="SITUATION" dataField="SITUATION" width="200"/>
                      </mx:columns>
                  </mx:DataGrid>
                 
                 
                  <s:Button label="Commit Updates" click="button1_clickHandler(event)"/>
                 
                  <s:HGroup width="90%" height="80%" verticalCenter="20" horizontalCenter="0">
                
                     
                      <mx:ComboBox width="476" id="cmbSituation" creationComplete="Situation_creationCompleteHandler(event)" dataProvider="  

                               {getAllTblsituationResult3.lastResult}" labelField="SITUATION" editable="true">
                         
                      </mx:ComboBox>
                     
                      <s:TextArea width="426" id="textArea" text="{getAllTblsituationResult3.lastResult.SITUATION}"/>

               

                      <s:Button label="Back" click="cmbSituation.selectedIndex = cmbSituation.selectedIndex-1 ; textArea.selectedIndex = textArea.selectedIndex-1"/>
                      <s:Button label="Forward" click="cmbSituation.selectedIndex = cmbSituation.selectedIndex+1 ; textArea.selectedIndex = textArea.selectedIndex-1"/>
                     
                            
                  </s:HGroup>
              </s:Application>

              • 4. Re: Can a ComboBox be used for Text Input ?
                ParaicKW Level 1

                Hello

                 

                Anybody any answers on this query to input text in combo box and have it updated in a database. I would be dissapointed in Flex if it can't be done and it would mean I can't develop my ideas on this language. I have looked all over to see if it can be done. I don't know if the component needs to be customized or if it can be done with the standard combo box

                 

                ParaicKW

                • 5. Re: Can a ComboBox be used for Text Input ?
                  SashaKeith Adobe Employee

                  As Jeffrey suggested, you can do this with the spark combobox. Replace the mx combobox with the spark one and you will be able to add new items: http://help.adobe.com/en_US/flex/using/WS70f0d54f063b9b081aac8d1d1247252e4a0-8000.html

                  1 person found this helpful
                  • 6. Re: Can a ComboBox be used for Text Input ?
                    ParaicKW Level 1

                    The Sample from Adobe uses an array. I tried to adapt it to use a Data Service with PHP/Mysql but I can't get it to work. Any Ideas ?

                     

                     

                    <fx:Script>
                            <![CDATA[
                                import mx.controls.Alert;
                                import mx.events.FlexEvent;
                               
                                import spark.events.IndexChangeEvent;
                               
                                // Event handler to determine if the selected item is new.
                                protected function myCB_changeHandler(event:IndexChangeEvent):void
                                {
                                    // Determine if the index specifies a new data item.
                                    if(myCB.selectedIndex == spark.components.ComboBox.CUSTOM_SELECTED_ITEM)
                                        // Add the new item to the data provider.
                                        myCB.dataProvider.addItem(myCB.selectedItem);
                                }

                     

                               
                                protected function Situation_creationCompleteHandler(event:FlexEvent):void
                                {
                                    getAllTblsituationResult3.token = situationService.getAllTblsituation();
                                }

                     

                                protected function button1_clickHandler(event:MouseEvent):void
                                {
                                    situationService.commit();                   
                                }


                               
                            ]]>
                        </fx:Script>
                        <fx:Declarations>
                           
                            <situationservice:SituationService id="situationService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                           
                            <s:CallResponder id="getAllTblsituationResult3"/>
                         
                        </fx:Declarations>


                        <s:Button label="Commit Updates" click="button1_clickHandler(event)"/>
                       
                            <s:ComboBox width="363" id="myCB" change="myCB_changeHandler(event);" dataProvider="{getAllTblsituationResult3.lastResult}" labelField="SITUATION" creationComplete="Situation_creationCompleteHandler(event)" x="147" y="94">
                               
                            </s:ComboBox>

                          
                    </s:Application>

                     

                    ParaicKW