我使用的是 extjs3.4 版本,这里我无法在控制器中获取直接的表单引用。
task.MgmtContainerUi = Ext.extend(Ext.Panel, {
title: 'My Panel'
,width: 834
,height: 443
,layout: 'fit'
,header: false
,initComponent: function() {
this.items = [
{
xtype: 'grid'
....
....
}
,{
xtype: 'grid'
.....
.....
}
,{
xype:'form'
,fileUpload: true
,width: 498
,height: 350
,frame: true
,title: 'Upload a File'
,autoHeight: true
,id:'uploaderFileForm'
,ref: 'uploaderFileForm'
,bodyStyle: 'padding: 10px 10px 10px 10px;'
,labelWidth: 50
,defaults: {
anchor: '95%'
,allowBlank: false
,msgTarget: 'side'
}
,items: [{
xtype: 'fileuploadfield'
,id: 'DictUploadField'
,width: 350
,emptyText: 'Select an file'
,fieldLabel: 'Photo'
,labelWidth: 450
,name: 'file-path'
,buttonText: 'Browse ...'
}]
,buttons: [{
text: 'Upload'
,id:'uploadFileButton'
}
,{
text: 'Reset'
,id:'resetUploadFileButton'
}
,{
text:'Cancel'
,id:'cancelUploadFileButton'
}]
}
];
task.MgmtContainerUi.superclass.initComponent.call(this);
}
});
在控制器中,我为上传按钮编写了事件,如下所示
var uploadFileButton = Ext.getCmp('uploadFileButton');
uploadFileButton.on('click', this.onUploadFileButton, this);
然后我尝试在控制器中获取如下形式的引用
,onUploadFileButton: function(me, e){
var formRef = Ext.getCmp('uploaderFileForm');
formRef.getForm();
}
我得到了错误,因为 formRef.getForm() 不是方法。当我使用 firebug 进行调试时,我发现 formRef 将父组件作为面板指向,但 xtype 仍然只是表单。这里我无法调用 getForm 方法。
Ext.util.Observable
Ext.Component
Ext.BoxComponent
Ext.Container
Ext.Panel
Ext.form.FormPanel
原因是Ext.form.FormPanel is child for Ext.Panel
。
如何获取表格参考?在 extjs3.4 版本中还有其他实现文件上传的指针吗?
任何帮助,将不胜感激。