Skip to Content
0
Jun 08, 2016 at 05:17 AM

Dependency issue with custom formatter

23 Views

Hello,

I was referring below link to use custom formatter in my application:

https://sapui5.netweaver.ondemand.com/docs/guide/0f8626ed7b7542ffaa44601828db20de.html

This works fine but I need to take a different approach as per my Application framework. So I did the following things as below:

1. Create a formatter file under a specific folder

(function() {

'use strict';

jQuery.sap.declare("mytravelandexpense.formatter.myGenericFormatter");

mytravelandexpense.formatter.myGenericFormatter = {};

mytravelandexpense.formatter.myGenericFormatter.concatenateObjDesc = function(o, d) {

return 0 + ' -' + d;

};

});

2. I have created a dependency in my controller as below:

jQuery.sap.require("mytravelandexpense.formatter.myGenericFormatter");

3. Next I have used this formatetter in my view :

text="{ parts:[{path: 'Model1>CostObjectID'}, {path:'Model2>Description'}], formatter:'mytravelandexpense.formatter.myGenericFormatter.concatenateObjDesc'}"

But in console I see, it says the formatter is not found.

Could you please help me to understand where I am doing the wrong.

- Thanks , Somnath