Hi, I have a scenario to load a combobox on every loading of page in xml views.
The combobox doesnt load each time the page is called. It loads if i refresh the page else its blank. The data for the combobox is coming from a service and is called from actiondatareceived function which is called in onInit().
When i check in the networks tab of console the service is triggered but the dropdown just shows blank many a times
. Please find the code below.
<ComboBox items="{/results}" loadItems="loadcombo" id="comboid">
<items> <core:Item id="comboitemid" key="{ExpType}" text="{NameOfExpType}"/></items>
</ComboBox>
exptypemodel.read("/ExpenseTypeSet",{
filters: [Filter],
success:function(odata){
var combomodel = new sap.ui.model.json.JSONModel(odata);
sap.ui.getCore().setModel(combomodel,"exptypeid")
var combo = sap.ui.getCore().byId("InvoiceItemser--comboid");
combo.setModel(combomodel);
},
error:function(err){
console.log(err);
}
});
Request clarification before answering.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have found this erratic behaviour is due to some issue in backend as we are using a batch request. One of the requests fails and throws 400.
scn below. When im checking in error_log of gw it tells me to refer a note on how to use batch requests. I also tested with applying debug on ABAP side where the code is going in some exception when combobox is used.
Strangely this doesnt happen all the times. Sometimes the combobox loads and sometimes it doesnt thus giving this error


You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<ComboBox items="{exptypeid>/results}">
<items>
<core:Item id="comboitemid" key="{exptypeid>ExpType}" text="{exptypeid>NameOfExpType}"/>
</items>
</ComboBox>
exptypemodel.read("/ExpenseTypeSet",{filters:[Filter],
success:function(odata){
var combomodel =new sap.ui.model.json.JSONModel(odata);
sap.ui.getCore().setModel(combomodel,"exptypeid");
error:function(err){
console.log(err);}});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
can you try adding
combo.setModel(combomodel);
combomodel.refresh(true);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
trigger it by yourself
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do it before /after you navigate to that view
exptypemodel.read("/ExpenseTypeSet",{filters:[Filter],
success:function(odata){
var combomodel =newsap.ui.model.json.JSONModel(odata);sap.ui.getCore().setModel(combomodel,"exptypeid")
var combo =sap.ui.getCore().byId("InvoiceItemser--comboid");
combo.setModel(combomodel);},
error:function(err){
console.log(err);}});
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 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.