HI Experts,
I am working on HTML Views. I have a sap.m.List where I have added columns and Items related to the columns.
The issue here is I need to show the text in each row in a specific color code based on a specific flag.
I have created the CSS class as follows:
.textcolorblue{
color:#003399!important;
}
.textcolorbrown{
color:#663300!important;
}
I need to attach the css class dynamically to the items in the list for this I have written a formatter function and trying to attach the class using this. For the purpose of testing I am also trying to get the value of the formatter function in the text. The text is displaying the name of the class correctly.
<div data-sap-ui-type="sap.m.Text" class="{parts: [{path: 'ItemNumberFormatted'}], formatter: 'sap.mm.purchaseorder.approve.util.Conversions.listItemclass'}"
data-text="{parts: [{path: 'ItemNumberFormatted'}], formatter: 'sap.mm.purchaseorder.approve.util.Conversions.listItemclass'}"></div>
But the class to change the color is not applied on the text.
Formatter function:
- sap.mm.purchaseorder.approve.util.Conversions.listItemclass = function(sClassflag) {
if (sClassflag == '10' ) {
return'textcolorblue';
} else {
return'textcolorbrown';
}
};
Need help!