View Full Version : for loop problem

28 Jul 2011, 3:14 AM
I am storing contact information of people in json file. When I am trying to get information of a specific person I cannot read the whole array of phone numbers. Because I cannot include for loop in tpl. Some people have 1 phone number (work-home), some of them have two or more. I used hasMany property for storing the numbers. How can I read all phone numbers of a person? Here is example code piece:

this. formNewVersion = new Ext.Panel({
id: 'newform',
layout: 'fit',
scroll: 'vertical',
items: [
xtype: 'dataview',

tpl: [
'<tpl >',
'<div style="padding-left: 20px;">',
' name:' + record.get('name'),
'<div style="padding-left: 20px;">',
'Surname: '+ record.get('surname'),
'<div style="padding-left: 20px;">',
'occupation: '+ record.get('occupation'),
// problem starts from here, I want to read whole phoneNumbers array I couldnt put for loop here.
'<div style="padding-left: 20px;">',
'Work: '+ record.phoneNumbers().getAt(0).get('Work'),
'<div style="padding-left: 20px;">',
'Home: '+ record.phoneNumbers().getAt(0).get('Home'),
'<div style="padding-left: 20px;">',
'Mail: '+ record.get('mail'),
itemSelector: 'div.subeadres',
styleHtmlContent: true,
store: this.rehberStore

28 Jul 2011, 9:43 AM
Take a look at the XTemplate component in Sencha Touch API: