on 2017 Jun 10 3:30 PM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
1) setsizelimit in component.js file after model initialization. or
2) find exact model and set setsizelimit to correct model.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
your ui bind to this._oModel?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.