创建Extjs表格省略......
var fileImport;
var uploadForm = new Ext.FormPanel({
id: 'uploadForm',
width: 320,
frame: true,
fileUpload: true,
autoHeight: true,
labelWidth: 30,
enctype: 'multipart/form-data',
defaults: {
anchor: '83%',
allowBlank: true
},
items: [{
xtype: 'fileuploadfield',
emptyText: '请选择上传文件...',
fieldLabel: '文件',
id: 'uploadFile',
name: 'upload',
allowBlank: false,
blankText: '文件名称不能为空.',
buttonCfg: {
text: '选择...',
hidden: true
}
}],
buttons: [{
text: '导入',
handler: function() {
if (uploadForm.getForm().isValid()) {
uploadForm.getForm().submit({
url: "xxx.action",
method: 'POST',
waitTitle: '请稍后',
waitMsg: '正在导入文档 ...',
success: function(fp, action) {
uploadForm.getForm().reset();
sensitiveWordsLightGrid.refresh();
fileImport.hide();
},
failure: function(fp, action) {
fileImport.hide();
}
});
}
}
}, {
text: '重置',
handler: function() {
uploadForm.getForm().reset();
}
}, {
text: '选择文件',
handler: function() {
$('#uploadFile-file').click();
}
}]
});
$("#import").click(function() {
fileImport = new Ext.Window({
title: '批量导入',
width: 300,
height: 100,
autoHeight: true,
border: false,
plain: true,
modal: true,
layout: 'fit',
maximizable: false, // 禁止最大化
closeAction: 'hide',
closable: true, // 是否有关闭
collapsible: true, // 可折叠
iconCls: 'bind',
items: [uploadForm]
});
fileImport.setPosition(308, 260);
fileImport.show(this);
});