Hi Community,
I want to have two comboBoxes, where one of them should change its content dependent on the choice of the first Combobox.
I tried aggregation binding and element Binding (I may have made mistakes) but I was not able to connect the data into my ComboBox.
My actual "workaround" shows Data with and hard coded Path:
Test.view.js:
var errorGroupComboBox = new sap.m.ComboBox({ placeholder: "{i18n>menu.captureSite.incidentTab.selectErrorGroup}", items: { path: "errorCodes>/ErrorCode", template: new sap.ui.core.Item({ key: "{errorCodes>group}", text: "{errorCodes>groupDescription}" }) }, selectedKey : "{input>/myErrorGroup}" }); var errorGroupComboBoxLabel = new sap.m.Label({ text : "{i18n>menu.captureSite.incidentTab.errorGroupLabel}", labelFor : errorGroupComboBox }); incidentForm.addContent(errorGroupComboBoxLabel); incidentForm.addContent(errorGroupComboBox); var errorCodeComboBox = new sap.m.ComboBox({ placeholder: "{i18n>menu.captureSite.incidentTab.selectErrorCode}", items:{ path: "errorCodes>/ErrorCode/0/error", template: new sap.ui.core.Item({ key: "{errorCodes>code}", text: "{errorCodes>de_DE}" }) }, selectedKey : "{input>/myErrors}" });
The Controller got this code:
Test.controller.js:
onInit: function() { jQuery.sap.require("sap.ui.model.json.JSONModel"); var input = { date1 : new Date(), date2 : new Date(new Date().getTime() + 1000*60*60*24*7), date3 : new Date(), myDrink : "", myMachine: "", myErrorGroup: "", myErrors: "", takeAway : "" }; var model = new sap.ui.model.json.JSONModel(input); sap.ui.getCore().setModel(model, "input"); this.getView().setModel(model, "input"); // this.getView().setModel(new sap.ui.model.json.JSONModel(input), "input"); this.getView().setModel(new sap.ui.model.json.JSONModel("model/coffee.json"), "coffee"); this.getView().setModel(new sap.ui.model.json.JSONModel("model/equipments.json"), "equipments"); this.getView().setModel(new sap.ui.model.json.JSONModel("model/errorCodes.json"), "errorCodes"); this.bus = sap.ui.getCore().getEventBus(); }
My Example Data looks like this:
errorCodes.json:
{ "ErrorCode" : [ { "group" : 10, "groupDescription" : "Example Group Alpha" , "active" : true, "error" : [ {"code" : 100 , "de_DE" : "TestDaten 1", "en_EN": "test data 1" , "active" : true}, {"code" : 101 , "de_DE" : "TestDaten 2", "en_EN": "test data 2" , "active" : true}, {"code" : 102 , "de_DE" : "TestDaten 3", "en_EN": "test data 3", "active" : true } ] }, { "group" : 11, "groupDescription" : "Example Groupe Beta" , "active" : true, "error" : [ {"code" : 110 , "de_DE" : "DatenTest 4", "en_EN": "Data test 4" , "active" : true}, {"code" : 111 , "de_DE" : "DatenTest 5", "en_EN": "Data test 5" , "active" : true}, {"code" : 112 , "de_DE" : "DatenTest 6", "en_EN": "Data test 6", "active" : true } ] } ] }
My goal is to chose a "group" in the first combobox and then chose an "error" from this "group" in the second comboBox.
I hope you can give me some tips, links or even examples to help me with this issue.
Regards,
Dain