Skip to Content
0

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

Dec 19, 2016 at 06:19 AM

67

avatar image

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

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

3 Answers

Best Answer
Sudheer Kumar Akkalapotu Dec 22, 2016 at 05:59 PM
0

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
Share
10 |10000 characters needed characters left characters exceeded
Sudheer Kumar Akkalapotu Dec 22, 2016 at 05:59 PM
0

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
Share
10 |10000 characters needed characters left characters exceeded
Sebastian Kielhorn Apr 19 at 04:53 PM
0

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

Share
10 |10000 characters needed characters left characters exceeded