Spark Combobox with dataprovider is empty

There seems to be a bug when using a candle with an empty dataprovider combobox.  The idea is to have an empty combobox that adds all entries in the dataprovider for each group entered.  Attached is a simple project to demonstrate.  The first combobox has a dataprovider to the color 'Red', 'green', 'Blue' in it.  No matter what type in the box, whether it's an existing element or a new one, it displays in the label below.

The second combobox has a dataprovider that is currently empty.  Anything by typing in the box and pressing on enter does absolutely nothing.  There is no way to get the value entered in the combobox control now.

<?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">
 <fx:Declarations>
  <!-- Place non-visual elements (e.g., services, value objects) here -->
 </fx:Declarations>
 <s:Panel x="10" y="10" width="250" height="200" title="Combobox with dataprovider">
  <s:ComboBox x="10" y="10" width="228" id="cbFull">
   <s:dataProvider>
    <s:ArrayCollection>
     <fx:String>Red</fx:String>
     <fx:String>Green</fx:String>
     <fx:String>Blue</fx:String>
    </s:ArrayCollection>
   </s:dataProvider>
  </s:ComboBox>
  <s:Label x="7" y="37" text="Selected Item: "/>
  <s:Label x="94" y="37" text="{cbFull.selectedItem}"/>
 </s:Panel>
 <s:Panel x="268" y="10" width="250" height="200" title="Combobox with empty dataprovider">
  <s:ComboBox x="10" y="10" width="228" id="cbEmpty">
   <s:dataProvider>
    <s:ArrayCollection/>
   </s:dataProvider>
  </s:ComboBox>
  <s:Label x="15" y="41" text="Selected Item: "/>
  <s:Label x="102" y="41" text="{cbEmpty.selectedItem}"/>
 </s:Panel>
</s:Application>

Fill out a bug with your test case report.

Tags: Flex

Similar Questions

  • ComboBox with dataprovider HTTPService

    What I currently have is a comboBox that uses an httpservice dataprovider that sends xml data. I got this to work and it brings in my list. What I can't seem to find out is how to reference the selected data or label to make combobox then.

    The data should be similar to:
    < departments >
    Department < and > ALL < / Department >
    Department < and > accounting < / Department >
    Department < and > Administration < / Department >
    Department < and > Engineering Services < / Department >
    Department < and > Engineering Technology < / Department >
    Department < and > business technology < / Department >
    < service > HR < / Department >
    Department < and > information systems < / Department >
    Department < and > copy < / Department >
    < / departments >

    and the flex code is:
    < mx:HTTPService
    ID = "deptData".
    URL = "dept_xml.php" / >

    and the combobox control:
    < mx:ComboBox id = dataProvider = "{deptData.lastResult.departments.department"deptCombo"}" width = "200" / > "

    I tried all sorts of things like deptCombo.selectedItem.data, deptCombo.selectedItem.label deptCombo.selectedItem.department, but I can't figure out what to do to make it work.

    It is sometimes simple solutions that escape us. I tried to use deptCombo.text just to see and that worked. :)

  • ComboBox with customized with buttons listcell

    Hi all

    I would like to create a combobox with a custom listview that contains several controls. The thing is that setAction is consumed by the list of ComboBox popoup and then controls inside are ignored.

    There is here an example:

    //***************************************************************************************************************

    package javafxapplication3;

    Import javafx.application.Application;

    Import javafx.collections.FXCollections;

    Import javafx.collections.ObservableList;

    Import javafx.event.ActionEvent;

    Import javafx.event.EventHandler;

    Import javafx.scene.Scene;

    Import javafx.scene.control.Button;

    Import javafx.scene.control.ComboBox;

    Import javafx.scene.control.ListCell;

    Import javafx.scene.control.ListView;

    Import javafx.scene.input.MouseEvent;

    Import javafx.scene.layout.HBox;

    Import javafx.scene.layout.HBoxBuilder;

    Import javafx.scene.layout.StackPane;

    Import javafx.stage.Stage;

    Import javafx.util.Callback;

    SerializableAttribute public class JavaFXApplication3 extends Application {}

    @Override

    {} public void start (point primaryStage)

    ObservableList < String > options

    = (FXCollections.observableArrayList)

    "Option 1"

    'Option 2 '.

    );

    ComboBox < String > comboB = new ComboBox <>(options);

    Object obj = comboB.getOnAction ();

    comboB.setCellFactory (new reminder < < String > ListView, ListCell < String > > () {})

    @Override

    public ListCell < String > call (ListView < String > param) {}

    last cell ListCell < String > = new ListCell < String > () {}

    {

    super.setPrefWidth (100);

    }

    @Override

    {} public Sub updateItem (empty string element, Boolean)

    super.updateItem point, empty;

    If (item! = null) {}

    setText (item);

    HBox cell = HBoxBuilder.create () .children (createButton (), createButton () infrastructure ();

    setGraphic (cell);

    } else {}

    setText (null);

    }

    }

    };

    return the cell;

    }

    });

    Root StackPane = new StackPane();

    root.getChildren () .add (comboB);

    Scene = new scene (root, 300, 250);

    primaryStage.setTitle ("Hello World!");

    primaryStage.setScene (scene);

    primaryStage.show ();

    }

    private Button createButton() {}

    last button btn = new Button ("Hola");

    btn.setOnAction (new EventHandler < ActionEvent > () {}

    @Override

    {} public void handle (ActionEvent t)

    System.out.println ("Does´t work");

    }

    });

    btn.setOnMouseEntered (new EventHandler < MouseEvent > () {}

    @Override

    {} public void handle (MouseEvent t)

    System.out.println ("Works");

    }

    });

    return btn;

    }

    Public Shared Sub main (String [] args) {}

    Launch (args);

    }

    }

    //***************************************************************************************************************

    How could I do 'System.out.println ("work of Does´t");' works?

    A ComboBox control is used to select an element; from a set of predefined items (displayed in the context menu), or possibly by entering one. You intend something must be selected in your control? If so, it is not clear if something should be selected when the user presses the button. If this isn't the case, then a ComboBox control is not the appropriate control. Something like a menu button can work better.

    Assuming you want to use it to make a selection, a menu button might work if you used CustomMenuItems points the menu button and hideOnClick set to false:

    import java.util.Arrays;
    import java.util.List;
    
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.CustomMenuItem;
    import javafx.scene.control.Label;
    import javafx.scene.control.MenuButton;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.HBox;
    import javafx.scene.layout.StackPane;
    import javafx.stage.Stage;
    
    public class ButtonInMenuButtonItem extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            List options = Arrays.asList("Option 1", "Option 2");
            MenuButton menuButton = new MenuButton("Options");
            for (String option : options) {
                menuButton.getItems().add(createCustomMenuItem(option));
            }
            StackPane root = new StackPane();
            root.getChildren().add(menuButton);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setTitle("Hello World!");
            primaryStage.setScene(scene);
            primaryStage.show();
        }
    
        private CustomMenuItem createCustomMenuItem(String option) {
            HBox hbox = new HBox(5);
            hbox.getChildren().addAll(createButton(), createButton(), new Label(option));
            CustomMenuItem customMenuItem = new CustomMenuItem(hbox);
            customMenuItem.setHideOnClick(false);
            return customMenuItem ;
        }
    
        private Button createButton() {
            final Button btn = new Button("Hola");
            btn.setOnAction(new EventHandler() {
                @Override
                public void handle(ActionEvent t) {
                    System.out.println("Button pressed");
                }
            });
    //        btn.setOnMouseEntered(new EventHandler() {
    //            @Override
    //            public void handle(MouseEvent t) {
    //                System.out.println("Works");
    //            }
    //        });
            return btn;
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    

    If you do not want 'selection '. You should maybe use a button from menu above and manage the selection yourself.

  • Creation of ComboBox with the values of the fields

    Hey everyone, it's been a while since my last post.

    I spent some time trying to fill a ComboBox with the values of the 3 fields of different form of google and I was wondering if someone could tell me on common sense.

    Thanks a lot for any idea!

    the general idea would be something like this:

    Get added to a table field values

    var aItems = [];

    aItems.push (getField("Text1").valueAsString);

    aItems.push (getField("Text2").valueAsString);

    aItems.push (getField("Text3").valueAsString);

    Fill the drop-down list with the elements box

    getField("combo1").setItems (aItems);

    Replace domain names with real field names that you use.

    You can start the list with an element that is a single space (if it appears empty) or something like "- select -". You can also make sure you add all the duplicate entries, which would happen if all the field values are the same.

    When did you want this script to run?

  • ComboBox with default selected item

    Hello

    I try to view combobox with an item selected by default. Is it possible to use instead of selectedIndex selectedItem to achieve?

    Here is the code and I want User2 to be selected by default:

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"xmlns:local =" * "> "
    < mx:HBox id = "box" >
    < text mx:Label = "user:" / >
    < mx:ComboBox prompt = "Select" selectedItem = "User2" >
    < mx:dataProvider >
    User1 < mx:String > < / mx:String >
    User2 < mx:String > < / mx:String >
    < mx:String > user3 < / mx:String >
    < / mx:dataProvider >
    < / mx:ComboBox >
    < / mx:HBox >
    < / mx:Application >

    Please let me know if this is possible?

    Thank you

    You must pass a String OBJECT as a selectedItem.

    following code works:

    http://www.Adobe.com/2006/mxml '.

    "" layout = "absolute" xmlns:local = "*" >

    User1

    User2

    Util_3

  • Fill Combobox with nested XML

    Hello!
    How can I fill a ComboBox with an XML retrieved via a HTTPService?

    My XML looks like

    <? XML version = "1.0" encoding = "iso-8859-1? >
    < xml >
    < node label = value '1' = 'a' / >
    < node label = value "2" = "b" >
    < node label = "21" value = "ba" / >
    < node label = '22' value = 'bb' / >
    < node label = "23" value = "bc" / >
    < / node >
    < node label = '3' value = 'c' / >
    < node label = "4" value = "d" / >
    < node label = '5' value = 'e' / >
    < / xml >

    The output you want in the drop-down list would be

    one
    b
    -ba
    -bb
    Colombia-British
    c
    d
    e

    < mx:ComboBox id = "selectedLevel" dataProvider = labelField 'structure of {}"="label"/ >

    'structure' is an XMLListcollection, looks like my Resulthandler

    structure = new XMLListCollection (event.result.node);


    Can someone give me a hint what is missing?

    Thank you.

  • Fill ComboBox with XML data

    I would like to fill a ComboBox with data in a simple xml file like this. It's probably quite newbie question, but I couldn't find the answer to the search in this forum and the documentation up to date.


    < root >
    option 1 < item > < / item >
    option2 < item > < / item >
    Option3 < item > < / item >
    < / root >


    I would be very grateful if someone tell me how the ComboBox control to retrieve data from XML file. Thank you!

    I found a way to do it. Here is the code I use to populate a ComboBox control with dynamically loaded XML data (the XML content is in the first post).
    I'm sorry that I have opened a topic for this fundamental question. In any case I hope that the thread is useful for someone. If you think that there is something wrong with the code below, please post a reply.



    http://www.Adobe.com/2006/mxml"creationComplete ="parseXML (); » >


    public var myXML:XML
    public var myLoader:URLLoader

    function parseXML (): void {}
    myXML = new XML();
    var XML_URL:String = 'content.xml ';
    var myXMLURL:URLRequest = new URLRequest (XML_URL);
    myLoader = new URLLoader (myXMLURL);
    myLoader.addEventListener ("complete", xmlLoaded);
    }

    function xmlLoaded(evtObj:Event):void {}
    myXML = XML (myLoader.data);
    combo.dataProvider = myXML.children ();
    }

    ]]>




  • ComboBox with checkbox

    Hi all

    I want to display a combobox with the ablity to select multiple items and also be able to show the elements selected with different visual effects - I think that a checkbox to display selected/United Nations-selected item is more appropriate, but I can live with the alternative, like for example, highlight them selected with 'light green' etc.

    Is it possible to do so under JavaFX?

    Thank you

    DP

    import java.util.Arrays;
    import java.util.List;
    
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.scene.Scene;
    import javafx.scene.control.CheckMenuItem;
    import javafx.scene.control.ListView;
    import javafx.scene.control.MenuButton;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    
    public class MultipleSelectionDropdownTest extends Application {
    
        @Override
        public void start(Stage primaryStage) {
            final MenuButton choices = new MenuButton("Fruit");
            final List checkItems = Arrays.asList(
                new CheckMenuItem("Apples"),
                new CheckMenuItem("Oranges"),
                new CheckMenuItem("Pears"),
                new CheckMenuItem("Grapes"),
                new CheckMenuItem("Mangoes")
            );
            choices.getItems().addAll(checkItems);
    
              // Keep track of selected items
            final ListView selectedItems = new ListView<>();
            for (final CheckMenuItem item : checkItems) {
                item.selectedProperty().addListener(new ChangeListener() {
                    @Override
                    public void changed(ObservableValue obs,
                            Boolean wasPreviouslySelected, Boolean isNowSelected) {
                        if (isNowSelected) {
                            selectedItems.getItems().add(item.getText());
                        } else {
                            selectedItems.getItems().remove(item.getText());
                        }
                    }
                });
            }
    
            BorderPane root = new BorderPane();
            root.setTop(choices);
            root.setCenter(selectedItems);
            primaryStage.setScene(new Scene(root, 600, 400));
            primaryStage.show();
        }
    
        public static void main(String[] args) {
            launch(args);
        }
    }
    
  • ComboBox with customized view plugin

    Hello

    I used the plugin "Combobox with Custom Display".

    I have similar question

    When I entered the text in the textbox and scroll down using the keyboard button. The party highlight cannot scrolling with scroll.

    The demo link for above question

    http://Apex.Oracle.com/pls/Apex/f?p=35538:4

    kindly help me.

    Thank you

    Shiv says:
    Hello

    I used the plugin "Combobox with Custom Display".

    I have similar question

    When I entered the text in the textbox and scroll down using the keyboard button. The party highlight cannot scrolling with scroll.

    The demo link for above question

    http://Apex.Oracle.com/pls/Apex/f?p=35538:4

    kindly help me.

    Thank you

    Its a bug in the code of the plugin and not related to the APEX.

    I will study the issue and fix my code to resolve this problem, please bookmark this page http://www.apex-plugin.com/oracle-apex-plugins/item-plugin/combobox-with-custom-display_212.html and search for updates.

    Thank you
    Vikram

  • Creating a ComboBox with ActionScript

    I can't create a ComboBox with ActionScript. I want just a simple list, I can add and subtract.

    My Code:

    var inventory: ComboBox = new more.

    Error messages:

    Scene 1, Layer ' Layer 1 ', 1 environment, line 142 1046: Type was not found or is not a constant of compilation: ComboBox. "

    Scene 1, Layer ' Layer 1 ', 1 environment, line 142 1180: call to a method may not set ComboBox. "

    I don't know where I am going wrong. I found several example on the net which was code similar to mine, and some suggested adding the following:

    import fl.controls.ComboBox;

    That didn't work either and gave me more errors. Any suggetions?

    Thanks.

    I should have mentioned to keep this import line.

  • ComboBox with multiple columns

    Is it possible to make a ComboBox with two columns in the drop-down list box?

    Thank you

    Use the dropdownwidth property

  • Fill a ComboBox with actionscript

    I'm currently learning Flash 8 Pro by working my way through a book "Teach Yourself Flash 8' and met an teaching example that does not work." The (very basic) THAT the code needs to fill three lines of a ComboBox (with the instance name "MaZoneDeListeDéroulante"). I rechecked the syntax against that in the tutorial and it fits precisely. However, test results the film in errors such as:

    * Error * scene = scene 1, layer = Layer 1, frame = 1:Line 3: there is no method with the name "removeAll.
    and
    * Error * scene = scene 1, layer = Layer 1, frame = 1:Line 4: there is no method with the name "addItem".

    Can someone help a total Flash beginner who is unsure whether the error is in the tutorial or in its own implementation of it? Or even if there is something wrong with my installation of Flash? I'm learning this step tiny stuff at a time and I'm not convinced to go ahead until I have this problem to be resolved. Shaky foundations and all that.

    Thanks in advance.

    Here's the code AS I use:

    It is resolved. Turns out that I needed to delete the ASO files. I would have never known about this on my own, so thanks a lot go to the author, Phillip Kerman for her help.
    In any case, it is done and dusted.

  • Auto expand Spark Datagrid rowcount with dataprovider

    I have problems with a datagrid used within a VGroup.

    I put the datagrid view to display a line + the header with the requestedRowCount = - 1

    who says it has auto extend if several lines are added.

    When a filter is applied, I have reset the requestedRowCount number of rows + 1 (for header).

    monitoring indicates that the code is running

    However the datagrid lines never change.

    Is it because I'm not using the properties correctly or because it's within a VGroup?

    Any suggestion would be greatly appreciated... of the code snippets below...

    SamlpeScreenshot.png

    // Filter Rentals by Job
    if (arrRentalsByJob.filterFunction == null) arrRentalsByJob.filterFunction = filterByJob;
    trace('Rentals Done');
    arrRentalsByJob.refresh();
    if (arrRentalsByJob.length == 0) {
       trace('adjusting rentals to min - num rentals = ' + arrRentalsByJob.length.toString());
       // Set the DataGrid row count to the array length, plus one for the header.                    
       dgRentalSummary.requestedRowCount = 2;
    } else {
       trace('adjusting rentals to handle num rentals = ' + arrRentalsByJob.length.toString());
       dgRentalSummary.requestedRowCount = arrRentalsByJob.length + 1;
    }
    
    dgRentalSummary.invalidateDisplayList();
    

    <s:DataGrid id="dgRentalSummary" width="811" height="48" dataProvider="{arrRentalsByJob}" editable="false" requestedRowCount="-1" rowHeight="20">
    <s:columns>
      <s:ArrayList>
        <s:GridColumn dataField="rentalCompany" headerText="Rental Company" width="230"></s:GridColumn>
        <s:GridColumn dataField="rentalEquipment" headerText="Rental Equipment" width="500"></s:GridColumn>
        <s:GridColumn dataField="rentalCost" headerText="Cost" labelFunction="displayHours"></s:GridColumn>
    </s:ArrayList>
    </s:columns>
    </s:DataGrid>               
    

    Found the problem - using the tip of a previous post.

    Impossible to actually define a first 'height' for the DataGrid - and I don't need to set the number of lines when I filter.

    So... it works...

    // Filter Rentals by Job
    if (arrRentalsByJob.filterFunction == null) arrRentalsByJob.filterFunction = filterByJob;
    trace('Rentals Done');
    arrRentalsByJob.refresh();if (arrRentalsByJob.length == 0) {   dgRentalSummary.requestedRowCount = 2;} else {   dgRentalSummary.requestedRowCount = arrRentalsByJob.length + 1;}dgRentalSummary.invalidateDisplayList();
    
    
    
    
      
        
        
        
    
    
    
    
    
  • A new spark ComboBox item does not appear in textInput?

    I played with s:ComboBox and generally like them a lot. A detail is driving me crazy if is - most likely due to my lack of knowledge in this matter - that if I try to add a new item to my dataprovider in a changeHandler (recorded for the change event) the text for the ComboBox, textInput disappears - while adding item works perfectly. Interestingly enough the same operation works very well if it is called by clicking on a button, that is after the change event has been processed and the text does not disappear. To better understand what I'm talking about check out the code of http://help.adobe.com/en_US/flex/using/WS70f0d54f063b9b081aac8d1d1247252e4a0-8000.html#WS7 0f0d54f063b9b08626480d2124725f692c-7fff

    try to add a new item and press ENTER. Taking the same code of myCB_changeHandler and to use it as a button click event instead of a change event handler gives the behavior that I'm looking, i.e. the new element appears in the field of textInput CB and when clicking on the button added to the data provider while does not disappear from the textInput. Is there a way to accomplish this same behavior in the change event handler?

    Thank you!

    f

    Try callLater to postpone adding the item.

  • ComboBox with customized ItemRenderer

    It's my combobox when trying to get a custom converter:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:ComboBox xmlns:fx="http://ns.adobe.com/mxml/2009" 
                    xmlns:s="library://ns.adobe.com/flex/spark" 
                    xmlns:mx="library://ns.adobe.com/flex/halo">
         <fx:Script>
              <![CDATA[
              import mx.events.FlexEvent;
              import mx.collections.ArrayCollection;
              import mx.controls.CheckBox;
              public var datas:XML;
              [Bindable]
              var ItemRenderer:ClassFactory;     
              override public function set data(value:Object):void
              {
                   dataProvider = datas["sku" + value.sku];
                   ItemRenderer = new ClassFactory(comboBoxCheckBoxItemRenderer);     
                   itemRenderer = ItemRenderer;
              }               
              public function saveCheckState(evt:Event):void
              {
                   var dataProviderItem:Object = dataProvider.getItemAt(dataProvider.getItemIndex(selectedItem));
                   dataProviderItem.selected = CheckBox(evt.currentTarget).selected;
                   dataProvider.setItemAt(dataProviderItem, dataProvider.getItemIndex(selectedItem));     
              }
              ]]>
         </fx:Script>     
    </mx:ComboBox>
    
     
     
    This combobox is used as a custom itemrenderer in datagrid.
    Here is code for comboBoxCheckBoxItemRenderer:
    package modulecode
    {
         import mx.containers.HBox;
         import mx.controls.CheckBox;
         import mx.controls.Label;
         import mx.controls.Spacer;
     
         public class comboBoxCheckBoxItemRenderer extends HBox
         {
              private var action:Label;
              private var spacer:Spacer;
              private var checkBox:CheckBox;
              public function comboBoxCheckBoxItemRenderer()
              {
                   super();
              }
              override protected function createChildren():void {
                   
                   // Call the createChildren() method of the superclass.
                   super.createChildren();
                   action = new Label();
                   // Add the child component to the custom component.
                   addChild(action);
                   spacer = new Spacer();
                   spacer.percentWidth = 100;
                   // Add the child component to the custom component.
                   addChild(spacer);
                   checkBox = new CheckBox();
                   // Add the child component to the custom component.
                   addChild(checkBox);
              }     
              override public function set data(value:Object):void
              {
                   action.text = value.action;
                   checkBox.selected = value.selected;
              }     
         }
    }
    
    What's happening is that nothing is happening untill I drop combobox down in the grids. As the result checkboxes are not selected properly.
    Any help?
    
    
     
    

    I would try

    selected = "{XML (data) .selected == 'true'} '"

Maybe you are looking for