I googled how to change the color of a row inside a table ( ColumnListItem ) based on a value inside a column. I found a lot of google results and from all of the results I chose the one, which avoids to use predefined ( or individually defined ) css's inside my project folder. BTW, even inside the F12-browser-tools (modifying the css orsuch stuff at the frontend) seems not to work as expected.
I followed this approach ( quite old post ) and cannot get it working:
https://archive.sap.com/discussions/thread/3360580
The table line simply should become green, yellow, or red.
This is my code so far, inside onInit ( first part, creating the template )
var oTable = this.byId("companySecret");
var oView = this.getView();
var oTemplate = new sap.m.ColumnListItem({
cells: [
new sap.m.Text({
text: "{Col1}"
}),
new sap.m.Text({
text: "{Col2}"
}),
new sap.m.Text({
text: "{Col3}"
}),
//
// ALL OTHER COLUMNS
//
// The only difference is that I do this inside the "loop".
new sap.ui.commons.TextView({
text: "{Color}"
}).bindProperty("text", "Color",function(cellValue)
{
var backgroundColor = "red";
var cellId = this.getId();
var row_col = $("#"+cellId);
// As You see, I am quite desperate
$("#"+cellId).css("background-color","#FF0000");
$("#"+cellId).parent().css("background-color","#FF0000");
$("#"+cellId).parent().parent().css("background-color",'#FF0000');
$("#"+cellId).parent().parent().parent().css("background-color","#FF0000");
$("#"+cellId).parent().parent().parent().parent().css("background-color","#FF0000");
$("#"+cellId).parent().parent().parent().parent().parent().css("background-color","#FF0000");
return cellValue;
})
]
});
Immediately after these lines, the binding is initiated like this:
var sUrl = "/sap/opu/odata/sap/Z_COMPANY_SECRET/";
var oModel = new sap.ui.model.odata.v2.ODataModel(sUrl, false);
oTable.setModel(oModel);
oTable.bindAggregation("items", {path: "/Company_Secret", template: oTemplate });
So, what am I missing ? In the referred link the adopted answer is flagged as "helpful" so it MUST work. Any hints ? Thx in advance.