cancel
Showing results for 
Search instead for 
Did you mean: 

bindProperty using formatter function with addictional parameter

0 Kudos

Hi,

Is it possible to pass addictional parameters to formatter function?

Accepted Solutions (0)

Answers (2)

Answers (2)

naveenraj_a
Active Participant

Hi Dongqiang,

Try using "PARTS" parameter.

Syntax:

sap.m.Text({text:"{parts:[{path:'BaseAmount'},{path:'Currency'}],formatter:'util.Formatter.amount'}"})

Check this Link for more details.

OpenUI5 SDK - Demo Kit

Thanks

Naveenraj

0 Kudos

Sorry, it's 'additional'.

santhu_gowdaz
Active Contributor
0 Kudos

using "parts" you can do,

src="{
parts: [
'/address/street',
'/address/zip',
'/address/city',
'/address/country'
],
formatter: '.formatMapUrl'
}"

/>


SAPUI5 Explored

0 Kudos

seems 'parts' can only pass path parameters?

santhu_gowdaz
Active Contributor
0 Kudos

Sorry What you mean? mentioned path values are getting from the controller,In view you are specifying the path for that value and Formatter you will get it.

formatMapUrl: function(sStreet, sZip, sCity, sCountry) {
return "https://maps.googleapis.com/maps/api/staticmap?zoom=13&size=500x300&markers="
+ jQuery.sap.encodeURL(sStreet + ", " + sZip +  " " + sCity + ", " + sCountry);
}

former_member182862
Active Contributor
0 Kudos

Hi Dongqiang

Can you be more precise on what do you want to pass to the function?

Can you try to expand your question? It is hard for everyone if you have a one liner question and we have to guess.

Thanks

-D

0 Kudos

Hi Dennis,

I want to pass a string value, it's generated at runtime. I have put the value to a json model, so a specified path in 'parts' can find it.

former_member182862
Active Contributor
0 Kudos

Hi Dongqiang

I believe that you can create a model on the fly to handle this.

var model = new sap.ui.model.jsnon.JSONModel({

     constant1 : 'Hello',

     constant2 : 'World'

});

sap.ui.getCore().getModel(model, 'constants');

then in the parts property, you can do

parts: ['constants>/constant1','constants>/constant3']