Skip to Content
avatar image
Former Member

Display sap.m.table cells font color dynamically based on other cells/columns comparison.

Hi,

I saw few examples to color the table cells using formatter function definition in columnlistitem.Please suggest / recommend sample code to read model data directly to validate and display colors of tablecells based on validations as column names also dynamic.

Regards,

Koti Reddy

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jan 19, 2015 at 10:01 AM

    Hi,

    as of now I tried to display colors dynamically for first column elements if cell content matches with some string but I font color is not changing.

    Tried below code from onUpdateFinished method .

    var items = sap.ui.getCore().byId("ViewId").byId("table").getItems();

          

            for (i = 0; i < items.length; i++) {

                  var item = items[i];

                  var obj = item.getBindingContext().getObject();

                  if (obj.status === "Not Well") {

                      $(item.$().find('td')[0]).addStyleClass("columnStyle1");}

                

            }

    from debugging , I was able to read all items and data as well but my CSS style is not adding to change font color of the first element.

    .columnStyle0 {

      color: red;

    }

    .columnStyle1 {

      color: green;

    }

    Please let me know your recommendations on above procedure.

    Regards,

    Koti Reddy

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 14, 2015 at 08:18 AM

    This is what you want or?

    Add comment
    10|10000 characters needed characters exceeded