Quantcast
Channel: SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 789

Item index in aggregation template

$
0
0

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.

  1. Display the sequence of the item
  2. Display a control when it is the first, last, even or odd template
  3. Pass it as a parameter to an event
  4. 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?


Viewing all articles
Browse latest Browse all 789

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>