on 06-08-2016 6:17 AM
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
what's your folder structure and controller name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear,
I think I have placed either a very bad question or very hard question to answer Was expecting some help as I am stuck with this.
Will appreciate a reply/advice.
- Thanks , Somnath
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What is the name you have assigned to dependency in controller
Suppose in controller you have assigned as below -
sap.ui.define([
"sap/cdp/ums/managerequests/controller/BaseController",
"mytravelandexpense/formatter/myGenericFormatter"
], function(BaseController, formatter) {
"use strict";
return BaseController.extend("<namespace>.Object", {
formatter: formatter,
Change in view as below -
text="{ parts:[{path: 'Model1>CostObjectID'}, {path:'Model2>Description'}],
formatter:'.formatter.concatenateObjDesc'}"
BR.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.