jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox How to clear and make empty ComboBox?

This topic contains 2 replies, has 2 voices, and was last updated by  bosjabosja 13 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • How to clear and make empty ComboBox? #2091

    bosjabosja
    Member

    Hi,

    I succeeded to fill ComboBox with some items, but at some point I need to clear all the items from it and refill it with another items.
    How to do that? And is it possible to initialize empty ComboBox, with all functionality but with no items?

    Thank You

    Boban

    How to clear and make empty ComboBox? #2110

    Peter Stoev
    Keymaster

    Hi Boban,

    To initialize an empty ComboBox, you can use this:

     $("#jqxComboBox").jqxComboBox({ width: '200px', height: '25px' });

    To change the items of the ComboBox, you need to set its source property:

    For example:

    Initialize a ComboBox using this code:

                    var source = [
    "Affogato",
    "Americano",
    "Bicerin",
    "Breve",
    "Café Bombón",
    "Café au lait",
    "Caffé Corretto",
    "Café Crema",
    "Caffé Latte",
    ];
    // Create a jqxComboBox
    $("#jqxComboBox").jqxComboBox({ source: source, selectedIndex: 0, width: '200px', height: '25px', theme: theme });

    Then fill the ComboBox with new items using this code:

                    var newsource = ["Caffé macchiato",
    "Café mélange",
    "Coffee milk",
    "Cafe mocha",
    "Cappuccino",
    "Carajillo",
    "Cortado",
    "Cuban espresso",
    "Espresso",
    "Eiskaffee",
    "The Flat White",
    "Frappuccino",
    "Galao",
    "Greek frappé coffee",
    "Iced Coffee",
    "Indian filter coffee",
    "Instant coffee",
    "Irish coffee",
    "Liqueur coffee"];
    $("#jqxComboBox").jqxComboBox({ source: newsource });

    Best Regards,
    Peter Stoev

    http://www.jqwidgets.com
    jQWidgets Team

    How to clear and make empty ComboBox? #2130

    bosjabosja
    Member

    Thanks that was very helpful,
    but I have a situation where after filling ComboBox, I need to empty it, so it could be like after initialization, with no items at all.
    But it doesn’t help if I reinitialize it or fill it with empty array.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.