Skip to Content

Change table cell color in according to json value


in according to this tutorial ("") I try to set up a formatter. This have to change the color of table cells, for example if the value in the json is "TRUE" the color is green, if "FALSE" the color is red. After some tries I have no idea, what I'm doing wrong and hope someone of you can help me!?

Here the code of...


sap.ui.define([], function () {
	"use strict";
	return {
		changeColor: function (val) {
			if (val == "TRUE"){
			} else {


<Table id="paramTable" items="{/callbackData}" width="auto" class="sapUiResponsiveMargin">
      <Label text="Parameter"></Label>
    <Column width="10%">
      <Label text="Ist-Wert"></Label>
    <Column width="10%">
      <Label text="Soll-Wert"></Label>
    <Column width="30%">
      <Label text="Bemerkung"></Label>
        <ObjectIdentifier title="{key}"></ObjectIdentifier>
      <Text text="{path:'currentVal', formatter:'formatter.changeColor'}"/>
      <Text text="{operator} {targetVal}"></Text>


sap.ui.define([	"sap/ui/core/mvc/Controller",

], function(Controller, MessageToast, JSONModel, formatter) {
	"use strict";

	return Controller.extend("view.Main", {
		formatter : formatter,

                /*some other Code*/


Thanks in advance!

Add comment
10|10000 characters needed characters exceeded

2 Answers

  • Best Answer
    Posted on Mar 15, 2017 at 02:52 PM

    try using custom data way, easier for u to follow.

    do some google

    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 15, 2017 at 04:06 PM

    my guess is your formatter method is not called......there is '.' missing infront of formatter in XML

    your old code below:

    <Text text="{path:'currentVal', formatter:'formatter.changeColor'}"/>

    New code: place '.' before 'formatter.changeColor' so it becomes'.formatter.changeColor' (notice . in the begining)

    <Text text="{path:'currentVal', formatter:'.formatter.changeColor'}"/>
    Add comment
    10|10000 characters needed characters exceeded