Skip to Content
0

How to bind JSON model to Action Select in SAPUI5?

Feb 13, 2017 at 03:03 PM

234

avatar image
Former Member

How do I bind a simple model to an Action Select in SAPUI5?

I found some outdated documentation but that's it.
So, the following in my controller.js does not work:

var f = new JSONModel();
f.setData("({'tooltip':'show me colors', 'systems':[{'name':'Item1','id':'111'},{'name':'Item2','id':'112'}]})"); //This is an existing "Action Select" in my view var oComboBox = this.byId("actionselectSystemChooser"); oComboBox.setModel(f); //apply the model above jQuery.sap.log.info("getModel: " + oComboBox.getModel().getJSON()); oComboBox.bindProperty("tooltip", "/tooltip"); var oItemTemplate1 = new sap.ui.core.ListItem(); oItemTemplate1.bindProperty("text", "name"); oItemTemplate1.bindProperty("key", "id"); oComboBox.bindItems("/systems", oItemTemplate1);

The model seems to be applied correctly (based on the log), but nothing shows up in the list. Even with and without changing the slash in front of the property does not work either.

Any ideas?

Thanks!

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

3 Answers

Best Answer
Veeraraghavan Narasimhan
Feb 13, 2017 at 03:50 PM
0

Hello Mario,

You have actually bound to a string and not a json object.

f.setData("({'tooltip':'show me colors', 'systems':[{'name':'Item1','id':'111'},{'name':'Item2','id':'112'}]})");        

Therefore you need to make it

f.setData({'tooltip':'show me colors', 'systems':[{'name':'Item1','id':'111'},{'name':'Item2','id':'112'}]});    

This will fix the issue. Remove the double quote and parenthesis.

Thanks and Regards,

Veera

Share
10 |10000 characters needed characters left characters exceeded
Srikanth KV Feb 13, 2017 at 03:46 PM
0

in setDatamethod remove first set of brackets inside quotes "({ 'tooltip': 'show me colors' should be "{ 'tooltip': 'show me colors'

f.setData("{
'tooltip' : 'show me colors' }");
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 14, 2017 at 07:20 AM
0

Thanks! That solves the issue...

Share
10 |10000 characters needed characters left characters exceeded