user3783327
user3783327

Reputation: 626

How to set the background-color of a SAPUI5 Table Column dynamically?

Assume a table with a date header (days 1 till 31) of a given year and month. The content of the table depends on the selected year and month of course. Now, for example, assume to set the background-color of all "weekend" columns to "gray".

With the following code (example from http://scn.sap.com/thread/3360580) we have some problems:

  1. we can only set the background of available data (assume a table with 10 default rows but only 2 entries; so we can only set the background of the first two entries)
  2. we "misuse" the tooltip property (or any other) to handle the background color
  3. removing of class value seems not working this way, if we change year/month of the bound table data we should change the color accordingly

    oTemplate.bindProperty("tooltip", bindPath, function(sValue) {          
    var classToSet = "";
    switch (sValue) {
        case "A": classToSet = "cssClassX"; break;
        case "B": classToSet = "cssClassY"; break;
        default: break;
     }
     cellId = this.getId();   
     $("#"+cellId).parent().parent().removeClass("cssClassX", "cssClassY");
     $("#"+cellId).parent().parent().addClass(classToSet);
    }
    

More or less the question is:

Is there a way to bound the background-color of a full table column on some data?

Upvotes: 0

Views: 5643

Answers (1)

Qualiture
Qualiture

Reputation: 4920

Wouldn't the sap.me.OverlapCalender be a better choice instead of using a table? Gives you way more freedom, especially when combined with the sap.me.CalendarLegend control

See https://sapui5.hana.ondemand.com/sdk/test-resources/sap/me/OverlapCalendar.html for a working example

Upvotes: 1

Related Questions