jQWidgets Forums
jQuery UI Widgets › Forums › Lists › ComboBox › How to clear and make empty ComboBox?
Tagged: combobox, javascript combobox, jquery combobox, jqxComboBox, ui combobox
This topic contains 2 replies, has 2 voices, and was last updated by bosjabosja 13 years, 2 months ago.
-
Author
-
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
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 Stoevhttp://www.jqwidgets.com
jQWidgets TeamThanks 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. -
AuthorPosts
You must be logged in to reply to this topic.