2017-06-28 4 views
0

Imは、ExtJS 3.2(ExtJSのこのバージョンにある必要があります)を使用しています。すべての内部のformpanelを持つパネルを表示するとうまく見えますが、パネルを閉じて[X]ボタンを押して再び開くと、すべてのフィールドラベルが2回表示され、テキストフィールドが消えます。 「キャンセル」ボタンを使用すると、正しく表示されます。Ext.formPanelは、閉じるボタンを使用してコンテンツを複製します。

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(); 
} 

答えて

1

closeAction : 'hide',が指定されているため、自動破棄されません。 そのプロパティをcloseと指定すると問題が解決されます。

+0

私は絶対に盲目で、それを見ませんでした。ありがとうございました! –

+0

それは私の喜びです。 –

0

あなたは、関数crearDoc(idControl)を呼び出して新しいフォームオブジェクトを作成しています。閉じるボタンを押したときにそれを破壊する必要があるので、autoDestroy:trueを設定します。 またはフォームを定義し、フォームを非表示にしてクリックボタンでフォームを表示するように設定します。

関連する問題