Skip to Content

Value of one Model is key to another - how to do this?

I have a sap.m.List that I create the list items from a JSON model (named model as "mainMenu"), the model is attached to my JSON view

{

"mainMenu": [{

"title": "Literature",

}, {

"title": "Video",

}, {

"title": "Presentations",

}]

}

To create the list, in my JSON view I use a list template...

var oListTemplate = new sap.m.StandardListItem({

title: "{title}",

type: sap.m.ListType.Navigation,

});

My issue is that I have a i18n resource model set on this view as well.

mainMenu_Literature=Literature

mainMenu_Video=Video

mainMenu_Presentations=Presentations

In my template I can't use...

title: "{i18n>?}"

because I have nothing to put into the ? spot.

What I'd like to do is change my JSON model to...

{

"mainMenu": [{

"title": "mainMenu_Literature",

}, {

"title": "mainMenu_Video",

}, {

"title": "mainMenu_Presentations",

}]

}

Then in the template use...

var oListTemplate = new sap.m.StandardListItem({

title: "{i18n>{mainMenu>/title}}",

type: sap.m.ListType.Navigation,

});

But, of course, that binding syntax is a fantasy.

My my problem is clear, I want to use the value of one model as the key to the second.

Suggestions?

Thanks.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Mar 24, 2015 at 04:17 PM

    Hi Dean,

    I tend to use a formatter function which returns the internationalized value for the model-bound property.

    See my answer on a similar question on Stackoverflow: How is localized data binding set up with JSON files and XML views?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.