PDA

View Full Version : Form.load() upgrading 2.x to 3.0 issue



tobiu
6 Jun 2009, 2:39 PM
hi together,

i have some problems with forms loading data before they are rendered.
in ext2.x i have windows containing forms.
on window.show() i am loading data for a form inside the window.
on the first load, the request - answer is faster than the animation of the window.show() und the form does not seem to be rendered yet.

with ext 2.x it did work though, with ext 3 the form keeps empty the first time the window is opened.

as a hotfix, i am using a listener on form.render to set the values again.

was there a change made on this with the new ext version?


thanks and kind regards, tobiu

tryanDLS
6 Jun 2009, 2:58 PM
Can you post a small sample that illustrates what you're seeing?

tobiu
6 Jun 2009, 3:10 PM
hi tim,

i can't post a full example that easy, since it needs an ajax-request to illustrate the issue.
basically my code lookes like:



Ext.namespace('bT');

showMessageWindow = function(messageId){

if (typeof(bT.showMessageWin) != 'object'){

bT.showMessageWin = new Ext.Window({
id : 'showMessageWinEl',
animateTarget : 'showMessageWinButton',
closeAction : 'hide',
resizable : false,
title : 'Show Message',
width : 675,
height : 450,
shim : false,
animCollapse : true,
buttons: [{
text : 'Close',
handler : function(){
showMessageWin.hide();
}
}],
items:
new Ext.Panel({
bodyStyle : 'padding:15px',
border : false,
layout : 'fit',
items : bT.showMessageForm = new Ext.form.FormPanel({
border : false
,method : 'post'
,url : 'ajaxHandler/ajaxHandler.php'
,labelWidth : 90
,defaults: {
width: 510
,msgTarget: 'side'
}
,baseParams: {
module: 'messageOperations'
}
,items : [
new Ext.form.TextField({
fieldLabel : 'Autor'
,name : 'author'
})
]
})
})
});
}

if(bT.showMessageWin.isVisible() === true){
bT.showMessageWin.hide();
}
else {
bT.showMessageForm.getForm().reset();
bT.showMessageForm.getForm().load({
params:{
id : messageId
,module : "getSingleMessage"
}
});
bT.showMessageWin.show();
}
};


and the red marked part does not work in ext 3, before the form is rendered.


kind regards, tobiu

Animal
6 Jun 2009, 11:45 PM
What if you add



renderTo: document.body,


to the Window config?

tobiu
7 Jun 2009, 4:33 AM
hi nige,

this is just a short part thrown out of a quite big app.
there is a toolbar-button to show / hide the window.


kind regards, tobiu

Animal
7 Jun 2009, 4:40 AM
OK.

SO what if you add renderTo: document.body to the Window config?

tobiu
7 Jun 2009, 5:26 AM
hi nige,

i tried the config, but it does not make a change since the formpanel inside the window still gets rendered after the show-animation.

to set renderTo : document.body to the formPanel is no option either, since that would destroy the whole layout for a short time on window.show(). though with that, elements exept html-editors get their value on window.show().

the formpanel onRender listener is quite a hack, but is working fine for me.
though i wonder what was different in ext 2.x.


kind regards, tobiu

Animal
7 Jun 2009, 5:55 AM
Ah! Animation!

Of course you want to postprocess the window after the show animation is over (first time it's shown)

tobiu
7 Jun 2009, 7:50 AM
hmm, i am still looking through the ext-sources to find any difference in setValues or the rendering-style, that could explain, why it worked in 2.x...

have not found a clue yet.