Note that there are some explanatory texts on larger screens.

plurals
  1. PONull in Flex ComboBox
    primarykey
    data
    text
    <p>How can you make a ComboBox where the user can select <code>null</code>?</p> <p>If you simply create a combobox with <code>null</code> in the dataprovider, the value appears but the user cannot select it:</p> <pre><code>&lt;mx:ComboBox id="cb" dataProvider="{[null, 'foo', 'bar']}" /&gt; </code></pre> <p>Is there a way to make that null selectable?</p> <p>A workaround is to add an item into the dataProvider that is not null but 'represents' null; and then map between null and that object every time you access the combobox. But that's not really an elegant solution; you would always have to keep this mapping in mind in all code that accesses a 'nullable' combobox...</p> <p>Edit: expanding on why I don't like the workaround: It could be done in a subclass of course, but either I introduce new attributes (like <code>nullableSelectedItem</code>); but then you have to be careful to always use these attributes. Or I override ComboBoxes <code>selectedItem</code>; but I'm affraid that is going to break the base class: it might not like something changing its idea of what the current selected item is from within. And even this fragile hack works, on top of <code>selectedItem</code> and <code>dataProvider</code> this nullItem then also needs to be handled special in <code>data</code> and <code>listData</code> for renderers, in <code>labelFunction</code>, and then it's probably still being exposed in events the ComboBox sends... It might work, but it's quite a hack just to fix the problem that if the user clicks on the item it isn't activated (for the rest the ComboBox handles null fine). (Another alternative is to have a ui component delegate to a ComboBox, but that's even much more code just to avoid this small problem)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload