Skip to Content
0

SAPUI5: Nest a binding inside another binding

Feb 15, 2017 at 06:25 PM

157

avatar image

Hi,

I am currently working on a SAPUI5 application, where I have ran into a problem I simply can't figure out and cannot find any information about on the internet.

Basically I have this code :

if(isPicklist) {
	column = new sap.ui.table.Column({
	width: "9em",
	filterProperty: columnName,
	sortProperty: columnName,
	defaultFilterOperator: "StartsWith",
	label: extension.value,
	template: new sap.m.Text({
	text: "{/PicklistLabel(locale='en_GB',optionId=10819L)/label}" 
		})						
});

The context of the code is that I am generating columns for a table, where I bind the text property as:

text: "{" + columnName + "}"
columnName

is a string of the column name from the ODataModel I am using. However, in the odata, some of the fields are "picklists" and therefore are foreign keys, where I have $expanded the ODataModel to join the needed Entities.

Now this is the problem. What I need is actually to bind the text as this:

text: "{/PicklistLabel(locale='en_GB',optionId={" + columnName + "})/label}" 

What I need is that it first retrieves the { columnName } binding (in this example it is "maritalStatus", and the put this foreignkey into the whole binding.

So basically I am trying to nest a binding. I need to get the foreignkey for every record and get the correct label - for example so it doesn't show the foreignkey "10819L" but the string "Single". The first code example where the "10819L" is hardcoded works, and every record gets "Single" in their label. So my bindings are correctly - Now I just need to make the solution dynamic.

Can someone please help?

Thank you very much!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers