代码之家  ›  专栏  ›  技术社区  ›  S. Moreno

Ext.formPanel使用关闭按钮复制内容

  •  0
  • S. Moreno  · 技术社区  · 7 年前

    Im使用ExtJS 3.2(必须在这个版本的ExtJS中)。当我显示一个内部有formpanel的面板时,一切看起来都很好,但当我从顶部用[X]按钮关闭面板并再次打开时,每个fieldlabel出现两次,textfield消失。如果我使用“Cancelar”按钮,则正确显示。

    How shows the first time

    Error

    我的代码:

        function crearDoc(idControl) {
            f = new Ext.FormPanel({
                frame: true,
                id: 'formFicheroCrear',
                layout: 'fit',
                defaults: {minWidth: 500},
                items: [{
                          xtype : 'hidden',
                          id : 'idFichero'
                       },
                        {
                           xtype: 'panel',
                           layout: 'form',
                           id: 'formReal',
                           width: '100%',
                           items: [{xtype: 'datefield',
                                   disabled: true,
                                   allowBlank : false,
                                   fieldLabel: 'Fecha',
                                   value : new Date(),
                                   format: 'd/m/Y',
                                   width: '100%',
                                   id: 'fechaDoc',
                                   allowBlank: false},
                              {xtype: 'textfield',
                               fieldLabel: 'Titulo',
                               allowBlank : false,
                               width: '100%',
                               id: 'nombreDoc'},
                              {xtype: 'textfield',
                                fieldLabel: 'Descripcion',
                                allowBlank : false,
                                width: '100%',
                                id: 'descripcionDoc'}]
                       },{xtype: 'panel',
                           layout   : 'fit',
                           items: [{xtype: 'htmleditor',
                               id: 'editorHTML',
                               allowBlank : false,
                               name: 'documentoTexto'}]
                       }],
                buttons: [{
                    //Guardar documento SGSI
                    text: '<bean:message key="label.boton.guardarySubir"/>',
                    minWidth: 100,
                    cls : 'x-btn-text-icon',
                    iconCls : 'yes-icon',
                    listeners:{
                        'close':function(win){
                                 console.info('bye');
                         },
                        'hide':function(win){
                                 console.info('just hidden');
                         }
    
                },
                    handler: function() {
                        // Comprobamos que el formulario esté OK
                        if (f.getForm().isValid()) {
                           var nombreDoc =  Ext.getCmp("nombreDoc").getValue();
                           var descripcionDoc =  Ext.getCmp("descripcionDoc").getValue();
                           var editorHTML =  Ext.getCmp("editorHTML").getValue();
    
                             Ext.Ajax.request(
                                     {
                        url: '/<bean:message key="global.application.context.name"/>/SGSI.do',
                        params: {"method": "crearDocumento",
                               "docTitulo": nombreDoc,
                               "docDescripcion" : descripcionDoc,
                               "docCuerpo" : editorHTML,
                               "idProyecto" :  Ext.getCmp('idProyecto').getValue(),
                               "idControl" : idControl}
                        })
                        ventanaCrearDocumento.close()
                        storeDocumentos.loadData(json);
                        Ext.getCmp('formFichero').getForm().reset()
                        } else {
                            Ext.Msg.alert('<bean:message key="label.sincronizador.atencion"/>',
                                            '<bean:message key="label.error.campos.rojo"/>');
                        }
    
                    }},
                    { text : '<bean:message key="label.boton.cancelar"/>',
                        cls : 'x-btn-text-icon',
                        iconCls : 'no-icon',
                        minWidth: 100,
                        handler: function() {ventanaCrearDocumento.close()}}]
            });
    
            f.load({
                url : '/<bean:message key="global.application.context.name"/>/SGSI.do',
                params : {
                    "method" : 'dameControlPorId',
                    "idControl" : idControl,
                    "idProyecto" : Ext.getCmp('idProyecto').getValue()
                },
                method : 'POST'
            });
        var ventanaCrearDocumento = new Ext.Window({
                height: 460,
                width: 700,
                closable: true,
                closeAction : 'hide',
                modal: true,
                title: 'Redacción de Documento',
                layout: 'fit',
                items: f
            });
            ventanaCrearDocumento.show();
     }
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   Ronak Patel    7 年前

    您已指定 closeAction : 'hide', 这就是为什么它不是自动销毁。 close 将解决问题。

        2
  •  0
  •   Gurumohan Singh    7 年前

    您正在通过调用函数crearDoc(idControl)来创建新的表单对象。您需要在按下关闭按钮时销毁它,因此设置自动销毁:true。