John the Ripper
John the Ripper

Reputation: 2439

Adding a null or empty value to a combobox at the top of the list

I would like my comboboxes to have the first value be empty so that the user can clear their previous selection. The comboboxes are bound to entities in the ViewModel. So how do I add this first value. I could used combobox.inert(0, new Entity), but is that the correct way?

This is for searching purposes: By default the combobox has no selection and the search will find everything. If they select an item the search is filtered.

Upvotes: 3

Views: 2152

Answers (1)

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174299

As your ViewModel is responsible for preparing the data to be displayed by the View, the ViewModel should add the empty element at the beginning of the collection that is then bound to the combobox.

Upvotes: 1

Related Questions