PDA

View Full Version : Load form not working



kyle
4 Aug 2009, 1:54 AM
Hi there

I have a form with tabpanels in it only shows the info loaded from a php file in the 1st tab and not in the rest

If I set the activeItem in the 2nd tab, the information appears in the 2nd but not in the 1st

Could you give me a hand on this?

Thanks in advance



............more code.............

/*********************
* FORM *
*********************/

Example.DatosEmpresa = Ext.extend(Ext.TabPanel, {

initComponent: function(){

var config = {
method: 'post'
,height: 380
,plain:true
,waitMsgTarget: true
,waitMsg : 'Espere por favor'
,activeItem: 0
,layoutOnTabChange: true
,hideMode:'offsets'
,items: [{
title: 'Datos Empresa'
,labelAlign: 'left'
,align: 'top'
,bodyStyle: 'padding:5px 5px 0'
,labelWidth: 50
,items:[{
columnWidth: 0.30
,layout:'form'
,border:false
,items:[{
xtype: 'textfield'
,fieldLabel: 'ID'
,name: 'id'
,maxLength: 15
,anchor: '95%'
}]
}]

},{
title: 'Datos facturacion'
,labelAlign: 'left'
,align: 'top'
,bodyStyle: 'padding:5px 5px 0'
,labelWidth: 50
,items:[{
layout:'column'
,border:false
,items:[{
columnWidth: 0.30
,layout:'form'
,border:false
,items:[{
xtype: 'textfield'
,fieldLabel: 'NAME'
,name: 'name'
,maxLength: 15
,anchor: '95%'
}]
}]
}]
}]
}

Ext.apply(this, Ext.apply(this.initialConfig, config));

Example.DatosEmpresa.superclass.initComponent.apply(this, arguments);

}
});

Example.VentanaEmpresa = Ext.extend(Ext.FormPanel, {

initComponent: function(){

this.DatosEmpresas = new Example.DatosEmpresa();

var config = {
closable:true
,align: 'top'
,method: 'post'
,width: 750
,height: 380
,plain:true
,layout: 'form'
,waitMsgTarget: true
,waitMsg : 'Espere por favor'
,reader: new Ext.data.JsonReader(
{},
[
'id', 'name'
])
,items: [{ name: 'id', xtype: 'hidden' }, this.DatosEmpresas ]
}

Ext.apply(this, Ext.apply(this.initialConfig, config));

Example.VentanaEmpresa.superclass.initComponent.apply(this, arguments);

this.on({
afterlayout:{scope:this, single:true, fn:function() {
this.getForm().load({url:'../Remote/edit_data_empresa.php', params:{identificador: this.identificador}});
}}
});
}
});

Ext.reg('formularioempresa',Example.VentanaEmpresa);

Animal
4 Aug 2009, 2:12 AM
This is because of deferred rendering.

I can't help you though. All that extend to configure nonsense is just obfuscating your code.

kyle
4 Aug 2009, 2:26 AM
Hi Animal and thanks for your quick response

Sorry but I don't understand your answer when you say something about that I am obfuscating the code.... please could you tell me what else you need?

I have tried to set deferredrender true & false with the same result

Regards

Animal
4 Aug 2009, 2:31 AM
How many instances of Example.VentanaEmpresa are you planning to create?

kyle
4 Aug 2009, 2:40 AM
In principle from 3 to 6, why?

Animal
4 Aug 2009, 2:53 AM
OK, so there's one reason for a subclass. You add no methods though, so I'm baffled as to why you don't just use a factory function to create a regular TabPanel according to a desired pattern:



function createVentanaEmpresa() {
return new Ext.TabPanel({
method: 'post',
height: 380,
plain: true,
waitMsgTarget: true,
waitMsg: 'Espere por favor',
activeItem: 0,
layoutOnTabChange: true,
hideMode: 'offsets',
items: [{
title: 'Datos Empresa',
labelAlign: 'left',
align: 'top',
bodyStyle: 'padding:5px 5px 0',
labelWidth: 50,
items: [{
columnWidth: 0.30,
layout: 'form',
border: false,
items: [{
xtype: 'textfield',
fieldLabel: 'ID',
name: 'id',
maxLength: 15,
anchor: '95%'
}]
}]

}, {
title: 'Datos facturacion',
labelAlign: 'left',
align: 'top',
bodyStyle: 'padding:5px 5px 0',
labelWidth: 50,
items: [{
layout: 'column',
border: false,
items: [{
columnWidth: 0.30,
layout: 'form',
border: false,
items: [{
xtype: 'textfield',
fieldLabel: 'NAME',
name: 'name',
maxLength: 15,
anchor: '95%'
}]
}]
}]
}]
});
}

Animal
4 Aug 2009, 2:54 AM
And note the proper Ext standard, readable code formatting!

kyle
4 Aug 2009, 5:11 AM
Hi again Animal

If I use function insted an exnted object, could I open several forms withour mixing data between them? (as you are saying)

Thanks

Animal
4 Aug 2009, 5:29 AM
Err.... have you read the code?

new creates things?

Well, you KNOW that don't you bacuse you "new" your own classes. So why are you asking?

kyle
4 Aug 2009, 5:46 AM
ahhhhhhhhhhhhhhhhhhh

ok,ok.. sorry I didn't understand so well how ''new' worked

I'm going to program by that way and I'll tell you

Many many thanks for your help

Animal
4 Aug 2009, 5:47 AM
You will need to add deferredRender: false into that function so that the TabPanel renders all its tabs when it first renders itself.