on ‎2020 May 15 8:19 PM
Hello,
I have defined 2 dependent comboBoxes and implemented element binding to accommodate the master-detail relationship in the binding between both. the code is below and it is working fine. The code is below.
I can however not find a way to set a default value in the second (dependent-detail) combobox. I would like to set the first item of the binded list as a default there.
<****************** view.xml *************>
<ComboBox id="comboSystemID" items="{/SystemSet}" selectionChange="onSystemSelected">
<core:Item key="{SystemId}" text="{SystemId}"/>
</ComboBox>
<ComboBox id="clientID" items="{ClientSet}">
<core:Item key="{ClientId}" text="{ClientId}"/>
</ComboBox>
<****************** controller.js *************>
onSystemSelected: function (oEvent) {
var sPath = sap.ui.getCore().byId(oEvent.getSource().getSelectedItemId()).getBindingContext().getPath();
var oClientID = this.byId("clientID");
oClientID.bindElement({ path: sPath });
// ---> how can I set here a default value based from the binding?
}
Any ideas?
thanks
Koen
Request clarification before answering.
Hi
Try this code - on before rendering ;
onBeforeRendering: function() {
console.log(this.getView().byId("SystemID").getSelectedKey());
var sPath = this.getView().byId("combobox_id").getBindingContext().getPath();
var oClientID = this.byId("clientID");
oClientID.bindElement({ path: sPath });
}
Regards,
Venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 7 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.