1

I want to change the color of the table cell, but I find it hard to transform the code to XMLView from JSView. Can you guys give me a hand ? What I've managed so far, is to add the text of the color, but what I want is to color the text itself (or the background)

Here is the code:

<ObjectIdentifier  
        title="{Invoices>BillValue}"  
        text = "{parts : [ 'Invoices>InvoiceRest' ],  
          formatter: 'Invoices.Formatter.BillColor'  
        }"/>

And in the "formatter" (I don't know why it doesn't want to format the text bellow :( ):

jQuery.sap.declare("Invoices.Formatter");
Invoices.Formatter = {
BillColor : function (fValue1) {  
try {   
if (Number(fValue1) > 0) {   
return "red";   
} else {   
return "green";   
}  
} catch (err) {        
return "None";      
}  }  };

Thanks

Nepriceputu
  • 76
  • 1
  • 6
  • Does this answer your question? [Define Color of ObjectStatus Text](https://stackoverflow.com/questions/51105161/define-color-of-objectstatus-text) – Boghyon Hoffmann May 29 '20 at 11:18

1 Answers1

0

var iDtemplate = new sap.m.ColumnListItem("idTemplate",{ type: "Navigation", visible: true, selected: true, cells:[

                   new sap.m.ObjectStatus({
                       text:"{SlNo}",
                   }).bindProperty("state", "number", function(value) {
                          return getStatusColor(value);
                   }),


                  new sap.m.ObjectStatus({
                       text:"{Name}",
                   }).bindProperty("state", "number", function(value) {
                          return getStatusColor(value);
                   }),
                   ],
                 pressListMethod: function(event){
                        var bindingContext = event.getSource().getBindingContext();

                 }
        });

        function getStatusColor(status) {
             if (status === '') {
               return "Error";
             } 

             else {
                 return "Success";
             }
            }

Based on the number field we are giving colors to columns Slno and Name.

anjaly
  • 518
  • 5
  • 12