on 08-15-2023 7:19 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.