cancel
Showing results for 
Search instead for 
Did you mean: 

Use static value for formatter in xml

1,341

I want to use a static value on xml, to use it in formatter. I found this comment on stackoverflow but this doesn't work for me.

I use the version 1.70, i see the feature is after 1.61 available.

My code:

{ parts: [
	{path: 'modelName>/processState'}, 
	{value: 'german'}
], formatter: '.translation'}

In my app i dont get any text.

EDIT:

You know the code above don't work.

If i change to this:

{ parts: [
	{path: 'modelName>/processState'}, 
	{path: 'modelName>/german'}
], formatter: '.translation'}


But in this solution i must set the property "german" to german in JS.

This is my formatter

translation: function(sKey, sLanguage){
	return this.text(sKey, sLanguage)
}

My OpenUI5 Version was 1.78.8

Accepted Solutions (1)

Accepted Solutions (1)

boghyon
Product and Topic Expert
Product and Topic Expert

It's a bug in UI5 which was reported last year and has been fixed since version 1.80. See the GitHub issue "CompositeBinding parts mixed with named models and StaticBindings incompatible when creating ...

Until the app can run with a newer version, you can circumvent the bug with the following temporary solution:

{
  parts: [
    { path: 'modelName>/processState' },
    { value: 'german', model: 'modelName' }
  ],
  formatter: '.translation'
}

Simply add the model name from one of the parts to the value binding info.

You might get an error log in the console but that can be ignored. Better update the UI5 version ASAP and remove the above workaround since SAPUI5 1.78 is already "out of maintenance".

____

Same issue: https://stackoverflow.com/q/61816223/5846045

Hello boghyon.hoffmann ,

Thank You for the greate Answer. It works with the temporary solution

But u have right, i increase the version!

Thank you very much. U made my day 🙂

Greetz

Answers (0)