on 07-07-2015 11:50 AM
When using a data aggregation on sap.m.Select
, the first entry is always selected. Here's a link to the SDK's preview.
Example code from my app
new sap.m.Select("id-names", {
width: '100%'
}).bindAggregation("items", "data>/trip/names", new sap.ui.core.Item(
{
text: "{data>Name}"
}));
There is a parameter called selectedKey
on the constructor to change this to another index. What I want is the select to be blank, because I want to force my users to make a choice, not blindly accept the first entry in the list.
I could force a blank entry in my aggregation data>/trip/names
but that would pollute my list.
Is there a better way to achieve this?
Hi Jorg,
You can handle this in UI logic.
Declare an empty array -
var jData = {"text":"--Select--","key":""};
Now add this array at starting of your model -
sap.ui.getCore().getModel().getProperty("data>/trip/names").unshift(jData);
First entry in your model will be blank.
Update: Oops, I forgot to check this condition in your post, Sorry! - I could force a blank entry in my aggregation data>/trip/names
but that would pollute my list.
The above logic is what I implemented, since we are not changing anything from the backend, It's just the model that associated with dropdown has been changed from UI. But, anyways it's a good question let's see if anyone can get solution for this.
Regards,
Sai Vellanki.
Message was edited by: Sai Vellanki
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey everyone,
There's an open issue for this out on github: https://github.com/SAP/openui5/issues/409
In the meantime, I'll roll with your suggestion and add an item to my dataset.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tried it out and it is kind of cumbersome
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dennis Seah First time only it's showing "--Select a trip--". After selecting any value,text will not be visible.using insert you added this text then it should be visible right?
Just comment this one and you will get the solution.
var sel = new sap.m.Select({
selectedKey: '{/selectedTrip}',
autoAdjustWidth: true,
items: {
path: '/trips',
template: new sap.ui.core.Item({
key: '{Name}',
text: '{Name}'
})
},
// change: function() {
// if (this.getFirstItem().getKey() === '') {
// this.removeItem(0);
// }
// }
});
Sorry Guys, My Mind is not working Thanks and Dhananjay Choubey
add a blank line to select (not to the model but to control), that's probably the best option for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please elaborate the solution Maksim Rashchynsk It will helpful for so many people including me.
Hi,
You can attach a blank item by addItem or insertItem method of the same.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use combobox,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is about a framework that does what I want, not about me fitting my requirements into the technicalities of the framework.
I can type in the combobox. I can't tap the combobox and get the dropdown, I need the tap the arrow. I don't want that. My app runs on a tablet that's used by people with big fingers
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.