zoukankan      html  css  js  c++  java
  • 【Extjs优化二】 Form表单提交通用

    /**
     * 提交表单
     */
    function $postForm(a) {
        if (a.formPanel.getForm().isValid()) {
            var b = a.scope ? a.scope: this;
            a.formPanel.getForm().submit({
                scope: b,
                url: a.url,
                method: "post",
                params: a.params,
                waitMsg: "正在提交数据...",
                success: function(c, d) {
                    Ext.ux.Toast.msg("操作信息", "成功信息保存!");
                    if (a.callback) {
                        a.callback.call(b, c, d);
                    }
                },
                failure: function(c, d) {
                    Ext.MessageBox.show({
                        title: "操作信息",
                        msg: "信息保存出错,请联系管理员!",
                        buttons: Ext.MessageBox.OK,
                        icon: "ext-mb-error"
                    });
                    if (a.callback) {
                        a.callback.call(b);
                    }
                }
            });
        }
    }





    使用改代码只需要13行代码 原始需要25-30行代码搞定 ,示例:

    	saveRecord: function() {
    	    $postForm({
    	        formPanel:this.formPanel,
    	        scope:this,
    	        url: __ctxPath + "/basedata/saveStudentDepartment.action",
    	        params:{},
    	        callback: function(d, f) {
    				var e = Ext.getCmp("StudentDepartmentGrid");
    				if (e != null) {
    					e.getStore().reload();
    				}
    				b.close();
                }
    	    });





  • 相关阅读:
    Python 函数装饰器简明教程
    *arg和**kwarg的区别
    克里金插值
    C语言Hello world
    ibatis错误
    typealias
    视图
    权限分级设置
    走出浮躁的泥沼:学会享受学习过程的乐趣
    R语言 eval(quote(x)) 和 eval(x)
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3002672.html
Copyright © 2011-2022 走看看