во-первых, извините, если мой английский плохой, ....
в моем скрипте переменная tplData ниже является динамической, ... (допустим, она генерируется из базы данных)
Таким образом, каждый ребенок может иметь другого ребенка. и так далее,....
теперь я в стеке, как итерировать, ..
var tplData = [{
name : 'Naomi White'
},{
name : 'Yoko Ono'
},{
name : 'John Smith',
child : [{
name:'Michael (John\'s son)',
child: [{
name : 'Brad (Michael\'s son,John\'s grand son)'
},{
name : 'Brid (Michael\'s son,John\'s grand son)',
child: [{
name:'Buddy (Brid\'s son,Michael\'s grand son)'
}]
},{
name : 'Brud (Michael\'s son,John\'s grand son)'
}]
}]
}];
var myTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div style="background-color: {color}; margin: 10px;">',
'<b> Name :</b> {name}<br />',
// how to make this over and over every child (while it has )
'<tpl if="typeof child !=\'undefined\'">',
'<b> Child : </b>',
'<tpl for="child">',
'{name} <br />',
'</tpl>',
'</tpl>',
///////////////////////////////////////
'</div>',
'</tpl>'
);
myTpl.compile();
myTpl.overwrite(document.body, tplData);