cancel
Showing results for 
Search instead for 
Did you mean: 

combobox should show only default value from oData

kp_25
Participant
0 Kudos

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");

It 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

Accepted Solutions (1)

Accepted Solutions (1)

turkaj
Active Participant
0 Kudos

Hi,

you can define a variable defaultValue. This variable has your default value. In the coding you can then check it in the For loop as follows:

for (var i = 0; i < data.results.length; i++) {
        if (data.results[i].Material === defaultValue) { // check if current material is default value
            arrayData = { id: data.results[i].Material }
            array.push(arrayData);
        }
    }

Regards
Jim

Answers (0)