on 10-26-2015 6:24 AM
Hi experts,
I want to make a field in a table coloured, So please guide me how to use formatter for a table field?
Piece of code that I have used for list formatter is like:
firstStatus: [ | ||||||
{ | ||||||
text:"{DeliveryStatus}", | ||||||
state:{ | ||||||
path:"DeliveryStatus", | ||||||
formatter: function(id) | ||||||
{ | ||||||
if(id == "Shipped") | ||||||
{ | ||||||
return "Success" | ||||||
} | ||||||
if(id == "Not Shipped") | ||||||
{ | ||||||
return "Error" | ||||||
} | ||||||
if(id == "In Process") | ||||||
{ | ||||||
return "Warning" | ||||||
} | ||||||
}}} | ||||||
] | ||||||
}); |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
var oControl = new sap.ui.commons.TextView().bindProperty("text", "bindpath",function(cellValue){
switch(cellValue){
case 'D1':
backgroundColor = 'red';
break;
case 'D2':
backgroundColor = 'blue';
break;
case 'D3':
backgroundColor = 'yellow';
break;
default:
backgroundColor = 'white';
}
cellId = this.getId();
$("#"+cellId).parent().parent().css("background-color",backgroundColor);
return cellValue;
});
var oColumn = new sap.ui.table.Column({label: new sap.ui.commons.Label({text: "Columnhead1"}), template: oControl});
oTable.addColumn(oColumn);
Working example at Color table cells depending on value of entry in row
where the color of the cells are changing based on male(m) or female(f) indicator in the JSON
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.