cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.ComboBox not displaying icon added in sap.ui.core.ListItem

Abdul_Waheed
Contributor

Hi I am new to UI5 I have written below code to display a Combo Box with List Items containing Icon and Text.

  <ComboBox width="25em">

       <sap.ui.core:ListItem icon="sap-icon://employee" text="{i18n>Person}" key="1"/>

       <sap.ui.core:ListItem  icon="sap-icon://factory" text="{i18n>Organization}" key="2"/>

  </ComboBox>

I am getting text but not Icon as shown below, some one guide me if i am making any mistake.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

yes, i Check code and icon cannot be supported.

so, sap.m.select

surely it will work.

         with in that use like this

                                   icon : sap.ui.core.URI (default: )

Former Member
0 Kudos

Hi M,

As Santhosh said currently it's not possible to display "image" or "icon" in dropdown. You can only display "text".

May be in future we will have this functionality.

Thanks and Regards,

Abhijeet

Abdul_Waheed
Contributor
0 Kudos

I see

former_member182862
Active Contributor
0 Kudos

Yes, I check the code and icon cannot be supported.

Thanks

-D

Abdul_Waheed
Contributor
0 Kudos

Thanks Dennis

Former Member
0 Kudos

Hi

Can you try with below option

function makeIconItems() {

return [

new sap.ui.core.ListItem({text:'CheckBox', icon:'images/ctrls/checkbox-icon.png'}),

new sap.ui.core.ListItem({text:'ComboBox', icon:'images/ctrls/combobox-icon.png'}),

new sap.ui.core.ListItem({text:'DatePicker', icon:'images/ctrls/datepicker-icon.png'}),

new sap.ui.core.ListItem({text:'DropdownBox', icon:'images/ctrls/dropdownbox-icon.png'}),

new sap.ui.core.ListItem({text:'RadioButton', icon:'images/ctrls/radiobutton-icon.png'}),

new sap.ui.core.ListItem({text:'RadioButtonGroup', icon:'images/ctrls/radiobuttongroup-icon.png'}),

new sap.ui.core.ListItem({text:'RatingIndicator', icon:'images/ctrls/ratingindicator-icon.png'}),

new sap.ui.core.ListItem({text:'Slider', icon:'images/ctrls/slider-icon.png'}),

new sap.ui.core.ListItem({text:'TextArea', icon:'images/ctrls/textarea-icon.png'}),

new sap.ui.core.ListItem({text:'TextField', icon:'images/ctrls/textfield-icon.png'}),

new sap.ui.core.ListItem({text:'PasswordField', icon:'images/ctrls/passwordfield-icon.png'}),

];

}

var oIconListBox1 = new sap.ui.commons.ListBox({

displayIcons:true,

items : makeIconItems()

}).placeAt("sample3");

var oIconListBox2 = new sap.ui.commons.ListBox({

displayIcons:true,

items : makeIconItems(),

visibleItems : 5

}).placeAt("sample3");

var oIconListBox3 = new sap.ui.commons.ListBox({

displayIcons:true,

items : makeIconItems(),

height: "200px"

}).placeAt("sample3");

Thanks

Prasad

Abdul_Waheed
Contributor
0 Kudos

Hi Durga,

I tried to use a custom icon with local path as you said. But no luck

santhu_gowdaz
Active Contributor
0 Kudos

Inn Combobox what ever mentioned  in text only displayed. so for "text" you can't add icon.

but using getIcon() method you can get selected item icon. But in combobox you can't show a icon as text.

http://jsfiddle.net/SanthoshGowda/ttjf3mge/6/

If you change, oItemTemplate1.bindProperty("text", "device"); it will shows the text but if you change icon, it won't.

Abdul_Waheed
Contributor
0 Kudos

I am trying to build a responsive ComboBox so i am using only sap.m controls

sap.ui.core.ListItem have  option to set Icon, so it should be able to show icon.

santhu_gowdaz
Active Contributor
0 Kudos

sap.ui.core.ListItem have  option to set Icon- i agree with you but combobox don't have option to show the icon. combobox will show only the tag "text" items so, you can't add icon to "text".

santhu_gowdaz
Active Contributor
0 Kudos

see ComboBox API-https://sapui5.hana.ondemand.com/docs/api/symbols/sap.m.ComboBox.html

for combobox you can add - key,text,additinalText. text and additionalText will be visible in combobox. But these 2 are text type so if you add icon to list also it will not visible here.

Abdul_Waheed
Contributor
0 Kudos

Ok. Thanks

sivakumar_mobility
Active Participant
0 Kudos

Hi,

Why you not use js combo box instead of XML.

TRY this

https://openui5.hana.ondemand.com/test-resources/sap/ui/commons/demokit/ComboBox.html#__2

With Regars,

siva.

former_member182862
Active Contributor
0 Kudos

Hi Siva

How is your answer relevant to M Follower's question?

Why do you think he should move away from XML?

Dennis (moderator)

Former Member
0 Kudos

Hi,

Have you checked with standard list item.

Please refer the link.

SAPUI5 Explored

You can also see the sample code there.

Thanks,

Sathish

Abdul_Waheed
Contributor
0 Kudos

Dear Satish,

SAPUI5 SDK - Demo Kit

I can see standard list item doesnt have option to set "Keys" for items.