Binding extjs5:为组件';海关财产
我有一个从filefield扩展的组件, 我在其中添加了一个自定义属性“serverPath”,并且定义了getter和setter 代码:Binding extjs5:为组件';海关财产,binding,viewmodel,extjs5,custom-binding,Binding,Viewmodel,Extjs5,Custom Binding,我有一个从filefield扩展的组件, 我在其中添加了一个自定义属性“serverPath”,并且定义了getter和setter 代码: Ext.define('MyApp.ux.Field.File',{ extend:'Ext.form.field.File', xtype:'myfilefield', serverPath:'', getServerPath:function(){ return this.serverPath; }, setSe
Ext.define('MyApp.ux.Field.File',{
extend:'Ext.form.field.File',
xtype:'myfilefield',
serverPath:'',
getServerPath:function(){
return this.serverPath;
},
setServerPath:function(serverPath){
this.serverPath = serverPath;
}
});
Ext.create('MyApp.ux.Field.File',{
bind:{
serverPath:'{serverPath}'
},
viewModel:{
type:'myViewModel'
}
});
我不会粘贴myViewModel的定义。这很简单
事实证明,这种绑定并不起作用
有人能帮忙吗?你的班级应该是:
Ext.define('MyApp.ux.Field.File',{
extend:'Ext.form.field.File',
xtype:'myfilefield',
config: {
serverPath:''
}
});
您应该已经准备好了,因为ExtJS将为您和setter创建setter和getter。
在视图模型中,确保您有:
data: {
serverPath : 'yourPathGoesHere'
}
已编辑
缺少两件事:
我已经尝试过你的建议,很抱歉发现它不起作用。嗨,如果你能提供某种JSFIDLE/Sencha小提琴,那就太好了,这样我可以更好地重新创建并可能帮助解决这个问题。嗨,太多thx给你了。整个问题都在这里:非常感谢!!!你的“懒惰”和“发布”策略做得很好!我对sencha文档有点失望,他们很少提到这两个配置属性,api文档对它们的解释也很糟糕。很高兴它能工作。如果答案正确,请选择它作为正确答案。