PDA

View Full Version : for loop problem



tubilik
28 Jul 2011, 3:14 AM
Hi,
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>',
'<div style="padding-left: 20px;">',
' name:' + record.get('name'),
'</div>',
'<div style="padding-left: 20px;">',
'Surname: '+ record.get('surname'),
'</div>',
'<div style="padding-left: 20px;">',
'occupation: '+ record.get('occupation'),
'</div>',
// 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>',
'<div style="padding-left: 20px;">',
'Home: '+ record.phoneNumbers().getAt(0).get('Home'),
'</div>',
'<div style="padding-left: 20px;">',
'Mail: '+ record.get('mail'),
'</div>',
'</div>',
'</tpl>'
],
itemSelector: 'div.subeadres',
styleHtmlContent: true,
store: this.rehberStore
}
]
});

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

http://dev.sencha.com/deploy/touch/docs/?class=Ext.XTemplate