cancel
Showing results for 
Search instead for 
Did you mean: 

sap.m.ComboBox only shows 100 items

thomas_arnesen
Explorer

Hi there

I've a ComboBox that will only display 100 items. Below is my code in the controller, populating the ComboBox, but only with the first 100 items:

var oNatio = oView.byId("selPersEditNatio");
var oNatioItemSelectTemplate = new sap.ui.core.Item({
	key: "{Land1}",
	text: "{NatioText}"
});
this._oModel.setSizeLimit(300);
oNatio.bindItems({
	path: "/CountrySet",
	template: oNatioItemSelectTemplate
});

When fetching the result set, all entries are returned - this is the request from the browser:

CountrySet?$skip=0&$top=300

When checking the result of this request, all entries are in the response.

But still, only the first 100 are shown in the combo box. Any idea why that is?

Thanks in advance;
Thomas

Accepted Solutions (1)

Accepted Solutions (1)

former_member221786
Active Participant

Hey Thomas,

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:

var oNatio = oView.byId("selPersEditNatio");
var oNatioItemSelectTemplate =newsap.ui.core.Item({key:"{Land1}",text:"{NatioText}"});
//this._oModel.setSizeLimit(300);
oNatio.bindItems({
	path:"/CountrySet",
	template: oNatioItemSelectTemplate,
        length: 300
});

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

thomas_arnesen
Explorer
0 Kudos

Thanks for this, and your blog entry. I've tried this out and works like a charm. Much tidier than setting the limit on the model when only needed for the combobox! (I swear I've read up on the ManagedObject methods but this Length setting must've escaped me... 🙂 )

former_member604407
Discoverer
0 Kudos

Thx. Works for me like a charm

Answers (6)

Answers (6)

In case you guys still looking for a solution for above issue.

Solution to set length in UI and in Controller

Pass length while binding the items for comboBox.

<ComboBox items="{path : 'DeliveryTimeSetModel>/',length : '500'}" id="dis_time" selectedKey="{soc_cart>DELIVERYTIME}" width="150px">

<sap.ui.core:Item text="{DeliveryTimeSetModel>Deliverytimedesc}" key="{DeliveryTimeSetModel>Deliverytime}"></sap.ui.core:Item>

</ComboBox>

Or if you want to set later in Controller

var Combobox = oView.byId("dis_time");
var oComboboxSelectTemplate =new sap.ui.core.Item({key:"{DeliveryTimeSetModel>Deliverytimedesc}",text:"{DeliveryTimeSetModel>Deliverytime}"});
oNatio.bindItems({
path:"DeliveryTimeSetModel>/",
template: oComboboxSelectTemplate,
length: 500
});

thomas_arnesen
Explorer

Thanks for your replies.

I found the culprit.

Later in the code, I set the size limit of the model back to 100 (as I only needed it to be 300 for this particular entity set and combo box). This seems to have affected the combobox when it got populated (even though all 100+ results were in the result set). Once I removed that additional size limit line, all works fine and the combobox displays all expected entries.

this._oModel.setSizeLimit(100);

This line of code was further down in my method so I didn't notice it when including the code in my initial question.

/Thomas

0 Kudos
  • Can you post your code block?
former_member182862
Active Contributor
0 Kudos

Hi Thomas

Appears that you are doing the right thing, can it be something else

http://jsbin.com/semawep/edit?html,js,output

thanks

Dennis

Sharathmg
Active Contributor
0 Kudos

I faced the same issue. For combo box this issue happened.

I changed the control to Select and that worked. Try that and then set size and bind the model. It should work.

Regards,

Sharath

thomas_arnesen
Explorer
0 Kudos

Hi Sharath

I have a sap.m.Select also and it's the same issue with it - only the first 100 items are visible in the drop-down even though all 240+ entries are in the result set.

Thanks,
Thomas

former_member227918
Active Contributor
0 Kudos

1) setsizelimit in component.js file after model initialization. or

2) find exact model and set setsizelimit to correct model.

junwu
Active Contributor
0 Kudos

your ui bind to this._oModel?