Skip to Content
avatar image
Former Member

How to bind JSON model to Action Select in SAPUI5?

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!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Feb 13, 2017 at 03:50 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 13, 2017 at 03:46 PM

    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' }");
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 14, 2017 at 07:20 AM

    Thanks! That solves the issue...

    Add comment
    10|10000 characters needed characters exceeded