Skip to Content
avatar image
Former Member

Not able to load all data in sap.m.CombBox from oDataModel

Hi,

I am using sap.m.ComboBox in our application. And to fetch the countries name in it
use oData Model. It is fetching the data (Country Name) in the control but not all countries items.(sap.m.ComboBox shows only 100 countries).

And I try to see the data which is attached to the sap.m.CoboBox control in console

by using this code sap.ui.getCore().byId("countrolName").getModel().oData

it is also showing the 100 countries. (But in database shows 200 countires)

Please suggest something to show all the items(data) in sap.m.ComboBox.

Thanks & Regards
Somdutt Sharma

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Dec 22, 2016 at 05:59 PM

    Hi Somdutt,

    The default size limit of the model in combobox is 100.

    You need to change the sizeLimit of the model explicitly before setting the model to the control.

    oModel.setSizeLimit(250); // if you are directly setting odata model use the limit based on your data
    
    oModel.setSizeLimit(oData.results.length); // if you are using json model
    
    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 22, 2016 at 05:59 PM

    Hi Somdutt,

    The default size limit of the model in combobox is 100.

    You need to change the sizeLimit of the model explicitly before setting the model to the control.

    oModel.setSizeLimit(250); // if you are directly setting odata model use the limit based on your data
    
    oModel.setSizeLimit(oData.results.length); // if you are using json model
    
    Add comment
    10|10000 characters needed characters exceeded

  • Apr 19, 2018 at 04:53 PM

    Hey Somdutt,

    I just wrote an Blog article about this subject so I wanted to propose one more solution which should be a little more elegant.
    If you want you can set sizeLimit per Binding. Just add parameter length to your Binding and your fine:

    <ComboBox
      items="{
        path: '/Country',
        length: 250
      }" >
      <items>
        <core:Item key="{CountryIsoCode}" text="{Text}" />
      </items>
    </ComboBox>

    Works also in Java-Script:

    var oControl= this.getView().byId("countrolName");
    oControl.bindItems({
    	path: "/Country",
    	template: new sap.ui.core.Item({key:"{CountryIsoCode}",text:"{Text}"}),
            length: 250
    });

    Maybe this is something which doesn't have that much side effects than setting sizeLimit for a Model globally.

    Also if you're interested see my whole article here

    Greetings,
    Sebastian

    Add comment
    10|10000 characters needed characters exceeded