Skip to Content

How to apply formatter to text in which is in table (Xml view)


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

	return Controller.extend("PPNBProjectPlanningNonBillable.controller.Detail", {
		formatter: formatter,
rest of the code.........


sap.ui.define([], function() {
	"use strict";

	return {

		statusColor: function(sValue) {
			if (sValue === "1") {
			} else if (sValue === "2") {
				//return "blue";
			} else if (sValue === "3") {
				//return "yellow";
			} else {
				//return "white";
				return sValue;




<Table showNoData="false" id="table1">
<Column  width="8%">
<Text  text="Level"/>
rest of the code.........

<ScrollContainer height="425px" vertical="true" focusable="true">
<Table    growing="true" growingThreshold="10" id="idProductsTable" inset="false" items="{ path: 'oDataModel>/Table' }">

<Text id="text1" text="{path:'oDataModel>Stufe' , formatter:'formatter.statusColor'}"/>

rest of the code.........


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Dec 11, 2017 at 09:39 AM

    Change the below line

    <Textid="text1" text="{path:'oDataModel>Stufe' , formatter:'formatter.statusColor'}"/>


    <Textid="text1" text="{path:'oDataModel>Stufe' , formatter:'.formatter.statusColor'}"/>
    Add comment
    10|10000 characters needed characters exceeded

    • From what I can see, the formatter function returns the color indicating the valueState of the control which displays as red/green/orange etc. sap.m.Text does not have any valueState property associated with it.

      Instead of using sap.m.Text within your table's items aggregation try using ObjectListItem as given here - SAPUI5 SDK - Step 23: Custom Formatters and show your text using an ObjectStatus where you also mention the formatter.