on 08-11-2016 7:32 AM
Hi All,
I'm trying to format values using formatter in table but it is not working and empty values are showing in table.
Please see my code and resolve my issue
In View:
.........
<items>
<ColumnListItem press="onPress">
<cells>
<Text id="otext1" xmlns="sap.m" text="{value1}" />
<Text id="otext2" xmlns="sap.m" text="{path:'value2' ,
formatter : '.formatter.converter'}"/>
<Text xmlns="sap.m" text="{value2}" />
<Text xmlns="sap.m" text="{value3}" />
<Text xmlns="sap.m" text="{value4}" />
In controller:
sap.ui.define([ "sap/ui/core/mvc/Controller", "chartswithxml/formatter" ],
function(Controller, formatter) {
"use strict";
return Controller
.extend("chartswithxml.S1",
{
formatter : formatter,
onInit : function() {
var oModel = new sap.ui.model.odata.ODataModel("Odata model/");
this.getView().setModel(oModel);
.........
Finally formatter.js
sap.ui.define([], function () {
"use strict";
return {
converter : function (sConverter) {
//var s = this.getView().getModel().getData();
return sConverter/1000;
}
};
});
Hi,
I resolved this issue by adding 'data-sap-ui-xx-bindingSyntax="complex"' to the bootstrap of SAPUI5 in index.html.
Regards,
Sai Ram Dinesh Pallapotu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you confirm your formatter is actually loaded (check network tab of your dev tools)? Is there any error message appearing (check console tab of your dev tools)?
If so just put a breakpoint in your formatter and see what's happening.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Are you getting the correct value from the field value2 from the OData service? Just for testing this have you tried removing the formatter and just setting the value of the Text element by binding it to value2?
<Text id="otext2" text="{value2}" />
Also why are you declaring the sap.m namespace within the Text element declaration? just write xmlns="sap.m" in the root tag of your view.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In the converter function in the formatter.js file, check by putting a breakpoint in developer console sources tab in Chrome and check if the field value2's value is successfully getting passed to the function.
I have declared an ObjectIdentifier which calls a formatter function like below:
<ObjectIdentifier
title="{path:'GrossAmount', formatter:'.formatter.converter'}"/>
The converter function in the formatter.js file is as below:
sap.ui.define([], function() {
"use strict";
return {
converter : function(amnt) {
return amnt/1000;
}
};
});
In the controller file:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast",
"com/demo/model/formatter"
], function(Controller, MessageToast, formatter) {
"use strict";
return Controller.extend("com.demo.controller.App", {
//ColumnListItem's press event handler
formatter:formatter,
With this I am getting the correct result.
Hi Sai,
Already you set the path to the table,so i think there is no need to mention path again like this:
<Text id="otext2" xmlns="sap.m" text="{path:'value2' ,
formatter : '.formatter.converter'}"/>
So please try this once :
<Text id="otext2" xmlns="sap.m" text="{value2 ,
formatter : '.formatter.converter'}"/>
Hope it works.
Thanks,
Deepak.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.