cancel
Showing results for 
Search instead for 
Did you mean: 

SAPUI5 - Changing icon color within ObjectListItem

former_member122654
Participant
0 Kudos

Hi,

I want to keep the same icon and only change the color depending on the status field.

In this way as described below, it definitely does not work. I think I have to use CSS but I have no idea how I can address CSS style. Unfortunately, the method addStyle does not apply to this case.

items: {

path: "/APP_DATA/TRANSDATA",

template: new sap.m.ObjectListItem({

type: "{device>/listItemType}",

press: [oController.handleListItemPress, oController],

intro : "{REPORT_CATEGORY}",                           

icon : {

path : "STATUS",

formatter : function(myStatus) {

if(myStatus=="CHECKED")

return sap.ui.core.IconPool.getIconURI({

src: "sap-icon://activity-items",

color: "#2DFA06",  //green

});

return sap.ui.core.IconPool.getIconURI({

src: "sap-icon://activity-items",

color: "#FC0519", // red

});

);

}

},



Any suggested solution?


Many thanks,

Fouad

Accepted Solutions (1)

Accepted Solutions (1)

former_member182862
Active Contributor

Hi Fouad.

Like this? Example

-D

former_member122654
Participant
0 Kudos

Hi Dennis,

exactly, many thanks! It looks like advanced stuff. With a few comments it would be perfect.

Fouad

Former Member
0 Kudos

Hi there,

nice solution Dennis!

I've created another version which uses more css and less javascript logic.

JS Bin - Collaborative JavaScript Debugging</title> <link rel="icon" href="h...

I've added some comments, but if you really want to understand whats going on, you should read through the links I've provied within the comments.

Greets,

ben

former_member122654
Participant
0 Kudos

Hi Ben,

Thanks for the solution and comments. With the references to the document your solution was easy to understand.

Thanks a lot!

former_member182862
Active Contributor
0 Kudos

HI Fouad

I was hacking this up in a few mins. Sorry for not providing information on how it is done.

-D

former_member122654
Participant
0 Kudos

No Problem Dennis, I am very thankful for any support.

Thanks,

Fouad

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Fouad,

which color do you want to change?

Greets,

ben

former_member122654
Participant
0 Kudos

Hi Ben,

i want to change the color of the icon.

check the link: SAPUI5 Icon Explorer

Thanks,

Fouad