cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

dependent combobox, element binding, set default element

Koen_VL
Participant
0 Likes
1,435

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

View Entire Topic
venkateswaran_k
Active Contributor
0 Likes

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