"nullable" option for sap.m.Select and similar controls
See original GitHub issueI’m not 100% sure that this is not a duplicate but couldn’t find a matching issue so I’ll create a new one. If this has been discussed earlier: sorry!
I’ve seen many cases now where we’d like to be able to tell a sap.m.Select that there should be a (default selected, always top-of-the-list) empty option. Selecting this would set selectedItem and selectedKey to null, trigger the change event etc. The OData annotations and metadata allows to mark a field as “nullable” which doesn’t work well with current selects. Currently our workaround is to include these empty options in the Model used for the binding but this introduces a lot of runtime overhead and code.
The API could look somewhat like that: Add two new properties:
- boolean
nullable
default false - string
nullableText
default “” // someone should be able to come up with a better name…
Somewhere between binding and rendering (updateItems?) there would be an additional “virtual” Item created that uses the nullableText
as a text and null (or the value of another property?) as its key.
This way selects wont always select the first data element and would require the user to pick the correct one. Additionally optional selects would be more easy to implement.
Using a combobox to fake that doesn’t feel good because of the input-behavior.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:31 (14 by maintainers)
@arleytriana
Just tried with forceSelection=false in 1.34.6 and obviously nothing is selected at first, but when the user has selected an entry, the selection can’t be removed anymore. For me this is only half a solution.
@stephania87
The alternative way is to insert a null value to a model and bind it to the select control. If using an OData model you could add a null value to the odata webservice read set and use a formatter function to swap the null Item text with a placeholder