Skip to Content
avatar image
Former Member

Combobox not loading every time page loads.

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Jun 21, 2017 at 12:13 PM

    trigger it by yourself

    Add comment
    10|10000 characters needed characters exceeded

    •     
      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);}});
  • avatar image
    Former Member
    Jun 22, 2017 at 06:26 AM

    can you try adding

    combo.setModel(combomodel);
    combomodel.refresh(true);
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 23, 2017 at 08:33 AM
    <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);}});
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 30, 2017 at 01:49 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 23 at 10:59 AM

    Info:

    If this not the issue.

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

    Regards,

    Gururaj

    Add comment
    10|10000 characters needed characters exceeded