Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

bind Aggregation using XSJS not working

hi ,

Need some help for the below issue.

I am not able to do bind aggregation on combobox to the result from XSJS.

Below is the result from XSJS service:

                       "rootnode": [                                   

                                    {

                                        "id": "2",

                                        "type": "Hybrids",

                                        "products": [

                                            {

                                            "model": "Accord hybrid"

                                               

                                            },

                                            {

                                            "model": "Civic hybrid"

                                               

                                            },

                                            {

                                            "model": "Insight"

                                               

                                            },

                                            {

                                            "model": "CR-Z"

                                               

                                            }

                                        ]

                                    },

                                    {

                                        "id": "3",

                                        "type": "Sport Utilities",

                                        "products": [

                                            {

                                                "model": "CR-V"

                                               

                                            },

                                            {

                                                "model": "Element"

                                               

                                            },

                                            {

                                           

                                                "model": "Pilot"

                                               

                                            }

                                        ]

                                    },

                                ]

                            }

I am using below bind aggregation on combo boxes,

var oModelCatPro1=new sap.ui.model.json.JSONModel("../../../Services/dropdown.xsjs");

  sap.ui.getCore().setModel(oModelCatPro1,"oModelCatPro1");

var listitms = new sap.ui.core.Item("idlistitms", {

  text : "{oModelCatPro1>type}"

  });

  //

  var drpDwn = new sap.m.ComboBox("iddrpDwn", {

  selectionChange  : [

  function(oEvent) {

  debugger;

  ddVal = sap.ui.getCore().byId("iddrpDwn").getValue();

  if(ddVal == "Hybrids")

  {

  drpDwn1.bindAggregation("items", "oModelCatPro1>/rootnode/2/products", listItms1);

  }

  else if(ddVal == "Sport Utilities")

  {

  drpDwn1.bindAggregation("items", "oModelCatPro1>/rootnode", listItms1);

  }

  },this]

  });

  drpDwn.bindAggregation("items", "oModelCatPro1>/rootnode", listitms);

var listItms1 = new sap.ui.core.Item("idlistItms1", {

text : "{oModelCatPro1>products}"

  });

  //

  var drpDwn2 = new sap.m.ComboBox("iddrpDwn1", {});

drpDwn1.bindAggregation("items", "oModelCatPro1>/rootnode/2/products", listItms1);

I am using 2 combo boxes , one combo box binds till type and based on the value of combo box 1 I need to populate combo box 2, which I am binding to products.

below are some of the results I got,

1) I am able to bind till rootnode-> type/id but I am not able to bind a value in product for combo box "drpDwn2".

any suggestions would be rewarded points and it would be a great help!!

Thanks!!

replied

Hi Sajith,

Instead of using if else and filtering through values, you could achieve it using model.

Please check the sample, I have used the same model that you used: JS Bin - Collaborative JavaScript Debugging


Regards,

Sai Vellanki.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question