Skip to Content
0

Combobox not loading every time page loads.

Jun 21, 2017 at 10:38 AM

167

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Jun Wu Jun 21, 2017 at 12:13 PM
0

trigger it by yourself

Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Its just giving me a loading busy indicator when i try to trigger the url read and bind to combobox on the loadItems event i.e whenever the combobox is clicked for inputs.

change & slectionChange events are not for my scenario.

0
    
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);}});
0

do it before /after you navigate to that view

0
avatar image
Former Member
Jun 22, 2017 at 06:26 AM
0

can you try adding

combo.setModel(combomodel);
combomodel.refresh(true);
Show 3 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Thanks for the answer, I tried refresh but its still the same.

Also another strange behaviour is when i debug the page during initialisation and finish debug adn stepout with F8 the dropdown loads.

0
Former Member

what about

setTimeout(function() {
combomodel.refresh(true);
}, 0);
0

he is using jsonmodel, refresh won't help.

0
avatar image
Former Member Jun 23, 2017 at 08:33 AM
0
<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);}});
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jun 30, 2017 at 01:49 PM
0

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


batch.png (40.9 kB)
Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 23 at 10:59 AM
0

Info:

If this not the issue.

>> Please check are you defining one more model without model name.

Regards,

Gururaj


scd.png (21.9 kB)
Share
10 |10000 characters needed characters left characters exceeded