PDA

View Full Version : Errors when open Ext.Window with htmleditor



Rafael
12 May 2009, 5:47 AM
The probleman is a htmleditor.
When open window with htmleditor in second time have this error:




this.wrap.dom is null
chrome://firebug/content/blank.gif this.wrap.dom.innerHTML = '';

this.dom is null
chrome://firebug/content/blank.gif return noBoxAdjust[(this.dom.tag...| "").toLowerCase()] || Ext.isBorderBox;


this.dom is null
chrome://firebug/content/blank.gif this.dom.style[camel] = value;


(c.getPositionEl ? c.getPositionEl() : c.getEl()).dom is null
chrome://firebug/content/blank.gif return (c.getPositionEl ? c.getP...l()).dom.parentNode == this.innerCt.dom;



and dont open !


function AbrirChamadoShow(QTD_Chamado){

var WI_AbrirChamado = Ext.getCmp('AbrirChamado');
if (!WI_AbrirChamado){
var FP_AbrirChamado = new Ext.FormPanel({
labelAlign: 'top',
frame:true,
title: 'Multi Column, Nested Layouts and Anchoring',
bodyStyle:'padding:5px 5px 0',
width: 600,
items: [{
layout:'column',
items:[{
columnWidth:.5,
layout: 'form',
items: [{
xtype:'hidden',
name: 'codigo_chamado',
id: 'codigo_chamado',
},
new Ext.form.TriggerField({
fieldLabel: 'Nome Empresa',
name: 'fantasia_nome',
id: 'fantasia_nome',
readOnly: true,
width: 320,
triggerClass: 'lookup',
onTriggerClick : function(){
LookupEmpresaShow();
},
anchor:'95%',
}),{
xtype:'textfield',
fieldLabel: 'Data Inicial do Chamado',
name: 'data_abertura',
id: 'data_abertura',
readOnly: true,
value: getData(),
anchor:'95%',
},{
xtype: 'checkbox',
fieldLabel: 'Agendar Visita',
align: 'left',
name: 'agendar_visita',
id: 'agendar_visita',
}]
},{
columnWidth:.5,
layout: 'form',
items: [{
xtype:'hidden',
name: 'codigo_cliente',
id: 'codigo_cliente',
},{
xtype:'textfield',
fieldLabel: 'Nome Funcionàrio',
name: 'nome_funcionario',
id: 'nome_funcionario',
readOnly: true,
value: '<?php echo $_SESSION["nome_funcionario"];?>',
anchor:'95%',
},{
xtype:'textfield',
fieldLabel: 'Hora Inicial do Chamado',
name: 'hora_abertura',
id: 'hora_abertura',
readOnly: true,
value: getHora(),
anchor:'95%',
},{
xtype: 'checkbox',
labelAlign: 'left',
fieldLabel: 'Finalizar Chamado',
name: 'finalizar_chamado',
id: 'finalizar_chamado',
listeners: {
check: function( cb, state ) {
if( state == true ) {
Ext.getCmp("observacao").setValue(Ext.getCmp("observacao").getValue() + "<br><center><b>Solução</b></center><br>");
}else{
Ext.getCmp("observacao").setValue(Solucao(Ext.getCmp("observacao").getValue()));
}
}
},
}]
}]
},{
xtype: 'htmleditor',
//xtype: 'textarea',
id:'observacao',
fieldLabel:'Observacao',
height:300,
anchor:'98%',
}],

buttons: [{
text:'Salvar',
formBind: true,
id: 'btn_salvar_chamado',

/*---------------- CADASTRA O CHAMADO NO BANCO DE DADOS -----------------*/
handler: function(){
//if( FP_AbrirChamado.getForm().isValid() ){
var dados_chamado = [];
dados_chamado.push( FP_AbrirChamado.getForm().getValues());
Ext.Ajax.request({
url: 'insert.php',
method:'POST',
params: { parametro: 'Chamado',
dados_chamado: Ext.util.JSON.encode(dados_chamado),
},
waitMsg: 'Salvando...',
success: function(response) {
var cod_retorno = Ext.decode(response.responseText);
Ext.MessageBox.alert('Status', 'Chamado Cadastrado com Sucesso!!!');
dsChamado.reload();
if( Ext.getCmp('agendar_visita').getValue() == 1 ) {
alert(cod_retorno.codigo_chamado); Agenda(Ext.getCmp("codigo_cliente").getValue(), Ext.getCmp("fantasia_nome").getValue(), cod_retorno.codigo_chamado);
}
else {
WI_AbrirChamado.close();
WI_AbrirChamado = null;
}
},
failure: function() {
Ext.MessageBox.alert('Status','Save failed');
}
});
}

},{
text: 'Atualizar',
id: 'btn_atualizar_chamado',
handler: function(){
var dados_chamado = [];
dados_chamado.push(FP_AbrirChamado.getForm().getValues());
Ext.Ajax.request({
url: 'update.php',
method:'POST',
params:{
parametro: 'Atualizar_Chamado',
codigo_chamado: Ext.getCmp("codigo_chamado").getValue(),
agendar_visita: Ext.getCmp("agendar_visita").getValue(),
finalizar_chamado: Ext.getCmp("finalizar_chamado").getValue(),
dados_chamado: Ext.util.JSON.encode(dados_chamado),
observacao: Ext.getCmp("observacao").getValue(),
},
success:function(response)
{
var msg_retorno = Ext.decode(response.responseText);
if( msg_retorno.success == true ){
if( Ext.getCmp('agendar_visita').getValue() == 1 ) {
Agenda(Ext.getCmp("codigo_cliente").getValue(), Ext.getCmp("fantasia_nome").getValue(), Ext.getCmp("codigo_chamado").getValue());
}
dsChamado.reload();
WI_AbrirChamado.close();
WI_AbrirChamado = null;
}
else {
alert("Erro");
}
}
});
},

},{
text: 'Cancelar',
id: 'btn_cancelar_chamado',
listeners: {
click: function() {
WI_AbrirChamado.close();
WI_AbrirChamado = null;
}
},

},{
text: 'Agenda',
id: 'btn_agenda',
handler: function(){
MostraAgenda(Ext.getCmp('codigo_chamado').getValue());
}
}],
});

var WI_AbrirChamado = new Ext.Window({
modal: true,
id: 'AbrirChamado',
title: "Abrir Chamado",
maximizable: true,
border: false,
layout: 'fit',
closeAction: 'close',
listeners:{
close: function(){
WI_AbrirChamado.destroy();
}
},
width: 700,
height: 520,
listeners: { close: function() { WI_AbrirChamado = null; } },
items: FP_AbrirChamado,
});

}
WI_AbrirChamado.show();
}

For test , i change htmleditor for textarea and work , but i need to use htmleditor.

Animal
12 May 2009, 5:55 AM
Overnest. You are putting a column layout Panel inside a FormPanel. Just set the FormPanel to be layout: 'column'.

Animal
12 May 2009, 5:57 AM
Oh no, I see. Your HtmlEditor is below that column Panel.

Condor
12 May 2009, 5:58 AM
Closing a window will destroy all inner items including the form!

Either reuse the window (and set closeAction:'hide') or also create a new form when creating a new window.

Animal
12 May 2009, 5:59 AM
Try making the FormPanel layout: 'anchor'

Animal
12 May 2009, 5:59 AM
Oh, I see. This one again!

Rafael
12 May 2009, 6:19 AM
Condor i try this in Window :


closeAction: 'hide',
listeners:{
beforehide: function(){
WI_AbrirChamado.destroy(); and try too WI_AbrirChamado.hide();
}
}

Dont work too.

Condor
12 May 2009, 6:47 AM
No, you didn't do what I said.

You have 2 options:

Option 1: Reuse the window

var win = Ext.getCmp('id-of-window');
if(!win){
var form = new Ext.form.FormPanel({...});
win = new Ext.Window({
id: 'id-of-window',
closeAction: 'hide',
layout: 'fit',
items: form,
...
});
}
win.show();

Option 2: Destroy and create

var form = new Ext.form.FormPanel({...});
var win = new Ext.Window({
id: 'id-of-window',
closeAction: 'close',
layout: 'fit',
items: form,
...
});
win.show();

Rafael
12 May 2009, 6:59 AM
the first option it is work.

Condor, have this error:


Denied permission to read the property XULElement.accessibleType
chrome://firebug/content/blank.gif this.doc.close();
Why this error ?

This is a button of close WIndow

text: 'Cancel',
id: 'btn_cancelar_chamado',
listeners: {
click: function() {
WI_AbrirChamado.close();
//WI_AbrirChamado = null;
}
},

Condor
12 May 2009, 7:01 AM
1. Ignore the error. It's not affecting how your application works and it should be removed in Ext 3 RC2.

2. You are supposed to be reusing the window now, so call win.hide() instead of win.close()!

Rafael
12 May 2009, 7:11 AM
I try with
cloaseAction: 'close'but dont work. When click in button :


listeners: {
click: function() {
WI_AbrirChamado.close();
}
},when i click in button for close window it is closed, and open window second time all field and button hidde but htmleditor it is only show

Condor
13 May 2009, 12:27 AM
Make up your mind: Are you recreating or reusing the window?

Rafael
13 May 2009, 2:11 AM
I use this


var _AbrirChamado = Ext.getCmp('ID_AbrirChamado');
if (!_AbrirChamado){
var FP_AbrirChamado = new Ext.FormPanel({
...
});
WI_AbrirChamado = new Ext.Window({
...
});
}
WI_AbrirChamado.show();

Condor
13 May 2009, 2:19 AM
With closeAction:'hide'?

In that case you also shouldn't call close().

Instead use:

WI_AbrirChamado.hide();
or (more precise):

WI_AbrirChamado[WI_AbrirChamado.closeAction]();

Rafael
15 May 2009, 1:47 PM
Condor, i change closeAction for close but when have a htmleditor in FormPanel, the others fields is hide, look at image


this.wrap.dom is null
chrome://firebug/content/blank.gif this.wrap.dom.innerHTML = '';

(c.getPositionEl ? c.getPositionEl() : c.getEl()).dom is null
chrome://firebug/content/blank.gif return (c.getPositionEl ? c.getP...l()).dom.parentNode == this.innerCt.dom;