Skip to Content
0
K P
Aug 15, 2023 at 06:19 PM

combobox should show only default value from oData

50 Views Last edit Aug 15, 2023 at 10:57 PM 2 rev

Hi , I have a design in which my table has a combobox on Material field and when the table shows initially it should only one value (coming from odata). right now the code I added shows all the material of the odata as dropdown.

success: function (data, response)

{ that.getView().getModel("appModel").setProperty("/returnOrderDetails", data.results); //var returnOrderDetails = that.getView().getModel("appModel").getProperty("/returnOrderDetails"); var arrayData; var array = []; for (var i = 0; i < data.results.length; i++) {
arrayData = { id: data.results[i].Material }
array.push(arrayData); //data.results[i].Material = array; //array.splice(0,array.length); } var jsondata = { items: array } var jsonModel = new sap.ui.model.json.JSONModel(); jsonModel.setData(jsondata); that.getView().setModel(jsonModel, "matModel"); // array.splice(0,array.length); //odef.setModel(jsonModel,"matModel");

image.pngIt should not show 10192049 in first row as it is second lines material.Second line shows both the materials with focus on second material.

View : <ComboBox id="mat" width="100%" items="{ path: 'matModel>/items'}" selectionChange="onSelectionChange" selectedKey="{appModel>Material}" selectedItem=""> <core:Item key="{matModel>id}" text="{matModel>id}"/> </ComboBox>

Controller

image.png

Attachments

image.png (6.4 kB)
image.png (44.8 kB)