fieldset的collapse和expand事件

id: 'emailalertform',
            xtype:'form',
            defaults: {
                '50%'
            },
            autoWidth: true,
            //frame: true,
            border: false,
            bodyStyle: 'padding:5px 5px 0',
            labelStyle: 'text-align: left',
            labelAlign: 'left',
            items:[{
                xtype: 'hidden',
                name: 'enable_email_hacklog_send',
                value: 0
            }, {
                id:'check_email_hacklog_send',
                xtype: 'fieldset',
                height:'auto',
                layout:'form',
                checkboxToggle: true,
                //checkboxName: 'enable_email_hacklog_send',
                title: EmailAlertMsg.enable_email_hacklog_send_box + EmailAlertMsg.emailHackLogRemark,
                collapsed: true,
                disabled:true,
                collapsedCls:'emailhacklogcss',
                listeners:{// 没有check事件,也没有value
                    'collapse':function(){
                        var form = Ext.getCmp('emailalertform'),
                            basicForm = form.getForm(),
                            ctrl = basicForm.findField('enable_email_hacklog_send'),
                            enabled = ctrl.getValue(),
                            fieldSetCtrl = form.getComponent(1);


                        if (enabled == 1) {
                            Ext.MessageBox.confirm(MainMsg.hintTitle,MainMsg.confirmCloseEmailSend,function(btn){
                                if (btn == 'yes'){
                                    Ext.Ajax.request({
                                        url: me.baseUrl2+'/edit',//数据操作是set_config
                                        method: 'POST',
                                        params: {
                                            "enable_email_hacklog_send": 0
                                        },
                                        success: function($) {
                                            var  resposeMsg = Ext.decode($.responseText);
                                            if(resposeMsg.success){//applySuccess
                                                //Ext.MessageBox.alert(MainMsg.okButton, MainMsg.applySuccess);
                                                ctrl.setValue(0);
                                            } else {
                                                Ext.MessageBox.alert(MainMsg.failTitle, resposeMsg.msg);
                                                fieldSetCtrl.expand();
                                            }
                                        },
                                        failure: function($) {
                                            Ext.MessageBox.alert(MainMsg.cancelButton, MainMsg.requestFail);
                                            fieldSetCtrl.expand();
                                        },
                                        scope: this
                                    });
                                }else{
                                    fieldSetCtrl.expand();
                                }
                            });
                        }
                    },
                    'expand':function(){
                        var form = Ext.getCmp('emailalertform'),
                            basicForm = form.getForm(),
                            ctrl = basicForm.findField('enable_email_hacklog_send'),
                            //enabled = ctrl.getValue(),
                            fieldSetCtrl = form.getComponent(1);
                        Ext.MessageBox.confirm(MainMsg.hintTitle,MainMsg.confirmOpenEmailSend,function(btn){
                            if (btn == 'yes'){
                                Ext.Ajax.request({
                                    url: me.baseUrl2+'/edit',//数据操作是set_config
                                    method: 'POST',
                                    params: {
                                        "enable_email_hacklog_send": 1
                                    },
                                    success: function($) {
                                        var  resposeMsg = Ext.decode($.responseText);
                                        if(resposeMsg.success){//applySuccess
                                            //Ext.MessageBox.alert(MainMsg.okButton, MainMsg.applySuccess);
                                            ctrl.setValue(1);
                                        } else {
                                            Ext.MessageBox.alert(MainMsg.failTitle, resposeMsg.msg);
                                            fieldSetCtrl.collapse();
                                        }
                                    },
                                    failure: function($) {
                                        Ext.MessageBox.alert(MainMsg.cancelButton, MainMsg.requestFail);
                                        fieldSetCtrl.collapse();
                                    },
                                    scope: this
                                });
                            }else{
                                fieldSetCtrl.collapse();
                            }
                        });


                    }
                },
                //hiddenName:combobox,
                //hidden:true,
                items:[{
                    xtype: 'checkbox',
                    name: 'enable_email_urgent_hacklog',
                    inputValue: 1,
                    id:'enable_email_urgent_hacklog',
                    labelStyle: 'padding:0 0 3px 0;',
                    fieldLabel: EmailAlertMsg.enable_email_urgent_hacklog_field,
                    boxLabel: EmailAlertMsg.enable_email_urgent_hacklog_box


                },{
                    xtype: 'numberfield',
                    name: 'email_hacklog_interval',
                    125,
                    fieldLabel: EmailAlertMsg.email_hacklog_interval_field,
                    id: "email_hacklog_interval",
                    listeners : {
                        render : function(obj) {
                            var font = document.createElement("font");
                            font.setAttribute("color","black");
                            var redStar = document.createTextNode("u00A0u00A0"+EmailAlertMsg.email_hacklog_interval_desc);
                            font.appendChild(redStar);
                            obj.el.dom.parentNode.appendChild(font);
                        }
                    }
                },{
                    xtype: 'numberfield',
                    name: 'email_hacklog_count',
                    125,
                    fieldLabel: EmailAlertMsg.email_hacklog_count_field,
                    id: "email_hacklog_count",
                    //hiddenName: "ddos_ack_attack_param",
                    //emptyText:EmailAlertMsg.email_hacklog_count_desc,
                    minValue: 1,
                    maxValue: 5000,
                    listeners : {
                        render : function(obj) {
                            var font = document.createElement("font");
                            font.setAttribute("color","black");
                            var redStar = document.createTextNode("u00A0u00A0"+EmailAlertMsg.email_hacklog_count_desc);
                            font.appendChild(redStar);
                            obj.el.dom.parentNode.appendChild(font);
                        }
                    }
                },{
                    xtype: 'combo',
                    store: me.schedulestore,
                    emptyText: EmailAlertMsg.selectTimeMgr,
                    125,
                    fieldLabel: EmailAlertMsg.email_hacklog_schedule_field,
                    id: 'emailalert_schedule_id',
                    hiddenName: 'email_hacklog_schedule',
                    mode: 'local',
                    triggerAction: 'all',
                    valueField: 'value',
                    displayField: 'text',
                    editable:false,
                    listeners:{
                        expand:function(){
                            me.schedulestore.reload();
                        },
                        render : function(obj) {
                            var font = document.createElement("font");
                            font.setAttribute("color","black");
                            font.setAttribute("style","padding-left: 17px");
                            var redStar = document.createTextNode("u00A0u00A0"+EmailAlertMsg.email_hacklog_schedule_desc);
                            font.appendChild(redStar);
                            obj.el.dom.parentNode.appendChild(font);
                        }
                    }
                },{
                    layout: 'form',
                    buttonAlign: "center",
                    hidden: this.btn_hidden,
                    buttons: [{
                        text: MainMsg.saveButton,
                        handler: function() {
                            this.saveTest(0,2);
                        },
                        iconCls: 'save',
                        scope: this
                    }, {
                        text: MainMsg.applyButton,
                        handler: function() {
                            this.saveTest(1,2);
                        },
                        iconCls: 'apply',
                        scope: this
                    }]
                }]
            }]

版权声明:本文为博主原创文章,未经博主允许不得转载。

原文地址:https://www.cnblogs.com/sunscheung/p/4839401.html