Skip to Content
0

Disable some items in MultiComboBox

Dec 04, 2017 at 12:54 PM

58

avatar image
Former Member

Hi everyone,

I have a MultiComboBox in which I want to disable some items. I have seen this example and also this one but both are for a ComboBox.

The problem is when I try the same thing, the items which are supposed to be disabled, disappear completely from the MultiComboBox (are invisible and not grayed out).

My guess is this is the default behavior in UI5. but does anyone know if I can make it work somehow?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

avatar image
Former Member
Dec 06, 2017 at 01:12 AM
0

Hi Mahnaz

We cannot tell because we do not have visibility on what you have implemented.

here is another example

http://jsbin.com/jocukon/1/edit?js,output

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks Deniss for your reply. As I have referred in my description, the example you provided works for a ComboBox and not a MultiComboBox.

let's assume a basic scenario: we want all of our items of the MultiComboBox to be disabled by default and later in the code we enable them. so I guess we would do something like this in XML file:

however, this makes all the items disappear but I simply want them to be grayed out.

<MultiComboBox width="190px"
....
    >
<core:Item key="{chartModel>name}" text="{chartModel>name}" enabled="false"/>
</MultiComboBox>
0
Former Member
Former Member

If you change sap.m.Select in your example to sap.m.MultiComboBox, you see that the first item is disappeared then.

0
Former Member

Hi Mahnaz

after reading the code,

https://github.com/SAP/openui5/blob/master/src/sap.m/src/sap/m/MultiComboBox.js#L2244

it is clear the mutlicombobox does not show disabled item.

Thanks

-D

1
Arjun Biswas Dec 05, 2017 at 04:05 AM
0

Hi ,

For enabling, you can use the setEnabled method and for hinding the items, you can use the setVisible method for your item object.

In your view use the foll. code :

	<MultiComboBox
                           id="myIP"
			width="500px"
			items="{
				path: '/Your_Entity_Set_Name',
				sorter: { path: 'Your_field_name' }
			}">
			<core:Item key="{Your_field_name}" text="{Your_field_name}" />
		</MultiComboBox>

Now in your controller in the on init method, you can implement the foll. code :

onInit:function(){
//here get all your list items and use the setEnabled method or the setVisible method for your required item.
}

Hope this helps,

Regards,

Arjun Biswas.

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

This does not work since sap.ui.core.Item does not have any method or property to set the visibility.
as I said, setEnabled (false) removes the item from the MultiComboBox.
I need a way to gray out the items.

0