question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"nullable" option for sap.m.Select and similar controls

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:31 (14 by maintainers)

github_iconTop GitHub Comments

7reactions
Frank683commented, Feb 12, 2016

@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.

3reactions
ghostcommented, Jul 30, 2018

@stephania87

  1. It should be validated and stored as a null value
  2. The key value should be a null, empty string or whatever ‘blank’ value that makes sense
  3. A ComboBox is not preferred here because the idea is to have a user forced to select or not select a null item without using input like behavior

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

sap.m.Select - API Reference - Demo Kit - SAPUI5 SDK
Determines whether the user can modify the selected item. When the property is set to false , the control appears as disabled but...
Read more >
Unable to add Items to select in SAP UI5
Hi Folks, I have created a sapui5 application in which i need to generate select items dynamically. I am fetching sub-departments by using ......
Read more >
Unable to set value as null to smart field in SAPUI5
I have used a smart field inside a Simple Form in a dialog fragment and the entity set was also bound correctly ,...
Read more >
Maxium items sap.m.Selection
Hello all, Can someone tell me what the maximum of items you can use in a sap.m.Selection object. I miss the second part...
Read more >
Action select drop drown controls values not filled?
Hi all, I am using sap.m.ActionSelect control from mobile library.I am using XML views.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found