Skip to Content

sap.m.ComboBox only shows 100 items

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Apr 19 at 04:45 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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... :) )

  • Jun 11, 2017 at 05:00 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Jun 11, 2017 at 04:29 AM

    your ui bind to this._oModel?


    Add comment
    10|10000 characters needed characters exceeded

  • Jun 11, 2017 at 04:32 AM

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

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 11, 2017 at 10:57 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 12, 2017 at 10:42 AM

    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

    Add comment
    10|10000 characters needed characters exceeded