Item index in aggregation template
We would like to have the index of aggregated element in the template generation. There are a lot of reasons someone needs the index of the aggregation item.
- Display the sequence of the item
- Display a control when it is the first, last, even or odd template
- Pass it as a parameter to an event
- Name an object according to the index
As an example we would like to use the index of aggregation in the name of a TextField
_addressEditFormElementTemplate: function(oController) {
return new sap.ui.commons.form.FormElement(this.createId(‘fldAddress’), {
label: new sap.ui.commons.Label(this.createId(‘lblAddress’), {
text: ‘Address’
}
}),
fields: [
new sap.ui.commons.TextField(this.createId(‘inpAddress’), {
value: ‘{address}’,
name: ‘addresses[${index}].address’
})
]
});
}
Is it possible now?
Hi Anastasios,
it is not really what you are asking for but might help you anyway: You could use the index of the data you are binding the control to. This breaks, of course, when you apply sorters or filters. But if the index you are asking about is equivalent with the position of the item inside the aggregation, then this might help. Here's an example:
HTH,
M.
PS: Maybe you should have gone for a `Discussion` rather than a `Blog Post` to get some more attention ...