Here is my Sencha Touch 2 code which shows the JSON list data in the Ext.data.List component. I have used tpl for creating listed items. Now i am in the need of conveting this List to Nested List. But failed and i have no idea how can i move the list view's itemTpl to Nest List's getItemTextTpl?
Code with List
Ext.define('Mobile.view.ActionListView', {
extend: 'Ext.dataview.List',
xtype: 'actionsummary',
id: 'actionsummaryList',
config: {
title: 'Actions',
store: 'ActionSummaryStore',
//data:[{"Id":1,"TransactionType":"Transaction 1","ActionList":[{"Id":1,"Count":4,"Action":"Action Item 1","CurrentStatus":"Open"},{"Id":2,"Count":14,"Action":"Action Item 3","CurrentStatus":"Open"},{"Id":3,"Count":44,"Action":"Action Item 5","CurrentStatus":"Close"}]}],
emptyText: 'Loading action items...',
itemTpl: Ext.create('Ext.XTemplate', '<tpl for=".">',
'<div class="action-item-container"><p class="action-text">{TransactionType}</p>',
'<tpl for="ActionList"><tpl for=".">',
'<div><ul>',
'<li><a href="javascript:void(0)"><span class="action-count">{CurrentStatus}<tt>({Count})</tt></span><span class="btn-{Action}">{Action}</span></a></li>',
'</ul></div>',
'</tpl></tpl>',
'</div>',
'</tpl>'
)
}
});
New Code with Nested List
Ext.define('Mobile.view.ActionListView', {
extend: 'Ext.dataview.NestedList',
xtype: 'actionsummary',
id: 'actionsummaryList',
config: {
title: 'Actions',
store: 'ActionSummaryStore',
useTitleAsBackText: false,
onItemDisclosure: true,
//data:[{"Id":1,"TransactionType":"Transaction 1","ActionList":[{"Id":1,"Count":4,"Action":"Action Item 1","CurrentStatus":"Open"},{"Id":2,"Count":14,"Action":"Action Item 3","CurrentStatus":"Open"},{"Id":3,"Count":44,"Action":"Action Item 5","CurrentStatus":"Close"}]}],
itemTpl: Ext.create('Ext.XTemplate', '<tpl for=".">',
'<div class="action-item-container"><p class="action-text">{TransactionType}</p>',
'<tpl for="ActionList"><tpl for=".">',
'<div><ul>',
'<li><a href="javascript:void(0)"><span class="action-count">{CurrentStatus}<tt>({Count})</tt></span><span class="btn-{Action}">{Action}</span></a></li>',
'</ul></div>',
'</tpl></tpl>',
'</div>',
'</tpl>'
)
},
getTitleTextTpl: function () {
return 'Summary View';
},
getItemTextTpl: function (node) {
// return '<div><strong>{name}:</strong> <em>{description}</em></div>';
//replace this code with my above itemTPL
}
});