现在的位置: 首页 > 综合 > 正文

ExtJs 经典布局(二)

2018年02月12日 ⁄ 综合 ⁄ 共 1009字 ⁄ 字号 评论关闭

 

 

function getImportForm() {
	if (!importForm) {
		importForm = new Ext.FormPanel({
			labelWidth : 100,
			monitorValid : true,// 把有formBind:true的按钮和验证绑定
			baseCls : 'x-plain',
			fileUpload : true,
			defaults : {
				width : 200
			},
			defaultType : 'textfield',// 默认字段类型

			// 定义表单元素
			items : [{
						inputType : "file",
						fieldLabel : "文件路径",
						name : "excel"// hiddenName才是提交到后台的input的name
					}],
			buttons : [{
				text : '导入',
				formBind : true,
				type : 'submit',
				// 定义表单提交事件
				handler : function() {
					if (importForm.form.isValid()) {// 验证合法后使用加载进度条
						// 提交到服务器操作
						importForm.form.doAction('submit', {
									url : 'houseImport!importExcel.action',// 文件路径
									method : 'post',// 提交方法post或get
									params : '',
									// 提交成功的回调函数
									success : function(retForm, retAction) {
										if (retAction.result
												&& retAction.result.data == 'ok') {
											Ext.MessageBox.alert('提示',
													'导入数据成功!');
											win.hide();
											ds.load({
														params : {
															start : ptb.cursor,
															limit : ptb.pageSize
														}
													});
										} else if (retAction.result
												&& retAction.result.msg == 'error') {
											Ext.MessageBox.alert('提示',
													'导入数据失败!');
										} else {
											Ext.Msg
													.alert('错误',
															'服务器出现错误请稍后再试!');
										}
									},
									waitMsg : '批量导入数据...'
								});
					}
				}
			}, {
				text : "关闭",
				handler : function() {
					win.hide();
				}
			}]
		});
	}
	importForm.show();
	return importForm;
}

【上篇】
【下篇】

抱歉!评论已关闭.