Reputation: 626
I have a n XML View which holds a List and the the List holds CustomListItems with Input, ComboBox and so on.
Now I want to manipulate the properties of the controls like setEnabled(true) or false at runtime. For that i need to iterate the items of the list and access the controls. Right?
If I use getItems on a List i receive an array of ListItemBase. How can i get the controls which are embedded to a ListItem ?
Any help/hint is appreciated.
Upvotes: 0
Views: 944
Reputation: 3948
The ListItemBase
objects od List.getItems()
are actually your CustomListItems.
You can access all properties and methods of them directly (no casting in JavaScript).
var listItems = list.getItems();
for (var i = 0, len = listItems.length; i < len; i++){
var controls = listItems[i].getContent();
var input = controls[0];
var comboBox = controls[1];
// and so on.
}
But to your first question: If you use databinding to create your list then you should use databinding for your additional properties like enabled
too. You can use expression binding or multipart binding together with a formatter function to calculate the properties like enabled from any model data of your list row (relative binding path) and any other data from all available models (absolute binding path).
Also a good practice is to create a dedicated viewModel - a simple JSONModel that represents some state of your view and that can be bound to.
If you need an example please tell us more about what you are trying to accomplish.
Upvotes: 1