EXTJs3.2 如何在选择文件后,将文件名获取放textfield中?
Ext.onReady(function() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var boardName = new Ext.form.TextField({
fieldLabel: '文件名',
width: 200,
xtype: 'textfield',
id: 'boardName'
})
var boardRevision = new Ext.form.TextField({
fieldLabel: '文件类型',
width: 200,
xtype: 'textfield',
id: 'boardRevision'
})
/* var zipField = new Ext.data.Field({
xtype : 'field',
fieldLabel : '选择文件 ',
allowBlank : false,
inputType : 'file',
name : 'file',
emptyText : 'No file selected'
})*/
var fm = new Ext.FormPanel({
// url : 'uploadController.jsp?t=' + new Date(),
renderTo : Ext.getBody(),
layout : 'form',
title : 'CAD Upload',
height : 350,
width : 580,
padding : '20',
closeAction : 'hide',
plain : true,
autoScroll : true,
defaults:{
width:180
,allowBlank:false
,blankText:'该项不能为空!'
},
items : [boardName,{
xtype : 'box',
height : '30'
},boardRevision,{
xtype : 'box',
height : '30'
},{
xtype : 'field',
fieldLabel : 'Zip File ',
allowBlank : false,
inputType : 'file',
name : 'file',
emptyText : 'No file selected'
}], // Ext.getCmpId("fieldID").getValue();
buttons : [{
text : '开始上传',
handler : function() {
if (fm.form.isValid()) {
Ext.MessageBox.show({
title : '正在上传文件',
width : 240,
progress : true,
closable : false,
buttons : {
cancel : 'Cancel'
}
});
fm.getForm().submit();
} else {
Ext.Msg.alert("消息","请先选择文件再上传.");
fm.form.reset();
}
}
}]
});
});