Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DropdownBox occur error in chrome

Hi all,

I have a problem with ListBox control.

Now I have a DropdownBox, and set a list of listbox in it.When I zoom in the browser and click the dropdownbox, there is an error "Uncaught Error: "108.1818" is of type number, expected int for property "scrollTop" of Element sap.ui.commons.ListBox#__box0" .

Does anyone know how to solve this problem?

Former Member
replied

Oh, please no, do not ever think of using the addItem() method if you can avoid it Always use data binding

What I meant was using ListItems directly in your DropdownBox:

<commons:DropdownBox items="{/items}">

    <core:ListItem text="{title}" />

</commons:DropdownBox>

and since I take it you are using JSViews, here's the Javascript equivalent:


var oListItem = new sap.ui.core.ListItem({

  text : "{title}"

});

var oDropdown = new sap.ui.commons.DropdownBox().bindItems("/items", oListItem);

return oDropdown;

On a sidenote, I can recommend using XMLViews instead of JSViews. Since you can't write any code in the view, it forces you to write your logic in the controller. It also looks a lot cleaner, and you will find you will write less lines of code as you can see from the two examples

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question