Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

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

$
0
0

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.


Viewing all articles
Browse latest Browse all 6178

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>