Skip to Content
avatar image
Former Member

Disable some items in MultiComboBox

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

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

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 05, 2017 at 04:05 AM

    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.

    Add comment
    10|10000 characters needed 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.