天天看点

ext动态新增一行之二

ext 动态 新增行 新增一行(2)

-------------------------------------------------------------------------------------------

    //定义表单

    var simple = new Ext.FormPanel({

        labelAlign: 'left',

        title: '添加子部门',

        buttonAlign: 'right',

        bodyStyle: 'padding:5px',

        //width: 600,

        autoHeight: true,

        autoWidth: true,

        //

        frame: true,

        labelWidth: 80,

        // items: [ ]        ,

        buttons: [{

            text: '保存',

            type: 'submit',

            //定义表单提交事件

            handler: function(){

                if (simple.form.isValid()) {//验证合法后使用加载进度条

                    Ext.MessageBox.show({

                        title: '请稍等',

                        msg: '正在加载...',

                        progressText: '',

                        width: 300,

                        progress: true,

                        closable: false,

                        animEl: 'loding'

                    });

                    //控制进度速度

                    var f = function(v){

                        return function(){

                            var i = v / 11;

                            Ext.MessageBox.updateProgress(i, '');

                        };

                    };

                    for (var i = 1; i < 13; i++) {

                        setTimeout(f(i), i * 150);

                    }

                    //提交到服务器操作

                    simple.form.doAction('submit', {

                        url: newSaveOrgFrameUrl,//文件路径

                        method: 'post',//提交方法post或get

                        params: '',

                        //提交成功的回调函数

                        success: function(form, action){

                            if (action.result.msg == 'ok') {

                                Ext.MessageBox.show({

                                    title: '系统提示信息',

                                    msg: '添加成功!',

                                    buttons: Ext.MessageBox.OK,

                                    icon: Ext.MessageBox.INFO,

                                    fn: function(btn, text){

                                    }

                                });

                            }

                            else {

                                Ext.Msg.alert('添加错误', action.result.msg);

                            }

                        },

                        //提交失败的回调函数

                        failure: function(){

                            Ext.Msg.alert('错误', '服务器出现错误请稍后再试!');

                        }

                    });

                }

            }

        }, {

            text: '重置',

            handler: function(){

                simple.form.reset();

            }//重置表单

        }, {

            text: '取消',

            handler: function(){

                win.close();

            }//重置表单

        }]

    });

    //添加第一个fieldSet

    simple.add(first_Org_fieldSet);

    //菜单面板

    var panel = new Ext.Panel({

        bodyStyle: 'width:100%',

        autoWidth: true,

        autoHeight: true,

        //autoScroll: true,

        renderTo: Ext.getBody(),

        //

        title: '',

        bodyStyle: 'padding:10px;',

        tbar: [{

            xtype: 'tbseparator'

        }, newDept_action, { // <-- Add the action directly to a toolbar

            xtype: 'tbseparator'

        }],

        items: [simple]

    });

    return panel;

}