PDA

View Full Version : XTemplate with subtemplates



AndreyPris
29 Jan 2015, 4:57 AM
Can you help me with an example. I use MVC paradigm and have some troubles with defining component.

How can I access to the subtemplate and custom method inside template?



Ext.define('app.view.MyView', {
extend: 'Ext.view.View',
alias: 'widget.MyView',
store: 'app.store.MyStore',
autoScroll: true,
tpl: [
'<tpl for=".">',
'<div class="main">',
'<div class="{room}">',
'[{%testTpl.apply(values)%}]', // Error: testTpl is not defined
'[{%customMethod(args)%}]', //not defined
'</div>',
'</div>',
'</tpl>'
],
testTpl: [
'<p>{room}</p>'
],
itemSelector: 'div.main',
initComponent: function() {
var me = this;
me.callParent();
me.getStore().load();
},
customMethod: function(args){
//some code here
}
});

markcooper
29 Jan 2015, 11:18 AM
I think that you need some this' in there, and that your actual method will get mapped as 'doCustomMethod'... I think. I may be completely wrong and that is based off of reading the code for various components.

AndreyPris
29 Jan 2015, 11:32 AM
You are wrong. 'this' inside tpl refer to this template.