【发布时间】:2016-03-15 14:56:28
【问题描述】:
我正在尝试针对来自 dataview 的 tpl 内部的组合框值进行测试:
Ext.define('MyForm', {
extend: 'Ext.form.Panel',
items: [
{
xtype: 'combo',
name: 'my_combo',
},
{
xtype: 'dataview',
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<tpl if="this.test()">pass</tpl>',
'</tpl>'
,
{
test: function(){
//doesn't work
return this.getView().down('[name=my_combo]').getValue() == 'ok';
}
}),
}
]
});
这不起作用,因为this 引用了模板本身,我不知道如何从内部访问视图。
【问题讨论】:
-
您不能在 XTemplate 函数中引用视图。使用 ViewModel 可能会更好。