PDA

View Full Version : Problem with update html panel



Dark Assassin
1 Sep 2010, 6:17 AM
Hi guys,
i've another strange question. Only you ExtJS guru could help me...
I've a Panel which is created when the page open, next i've to do some operations and then update the html content of this panel.
Normally everything goes fine but when i use the Ext.Ajax.Request i've some issues.
I post the code and then explain you:


gridMansioni.getSelectionModel().on('rowselect', function(sm, rowIdx, r) {
var id = r.data.id_mans;
var detail = Ext.getCmp('detailPanel');// This is my panel;
//Firt Ajax Request
Ext.Ajax.request({
loadMask : true,
url : '../checklist/listaMLSearch.php',
params : {
action : 'search',
id : id
},
success : function(resp) {
var options = Ext.decode(resp.responseText);
Ext.each(options, function(op) {
//First Inner Ajax Request
Ext.Ajax.request({
loadMask : true,
url : '../checklist/lavorazioniSearch.php',
params : {
action : 'search',
id : op.id_lav
},
success : function(resp2) {
var options2 = Ext
.decode(resp2.responseText);

Ext.each(options2, function(op2) {
if (lavorazioni == '')
lavorazioni = lavorazioni
+ ' '
+ op2.nome;
else
lavorazioni = lavorazioni
+ ','
+ op2.nome;
});
},
failure : function(resp) {

}
});

});
detail.body.update('Lavorazione: '
+ lavorazioni + '<br>'); //This is the update of the panel
},
failure : function(resp) {

}
});
});


If i use this code everything works, but i need to have two different inner ajax request to different address so i want to update the panel just once.
But if i try to call the string "lavorazioni",that first inner request modify, out the ajax request Firebug says that the string is undefined(i declared it as an empty string).
So i don't know if i can explain my problem...hope that someone can help!!
Thanks guys!

ashaihullin
1 Sep 2010, 6:27 AM
may be instead this:

if (lavorazioni == '')
you should check for:

if (lavorazioni == undefined)

i didn't find declaration of this string...

Dark Assassin
1 Sep 2010, 6:31 AM
may be instead this:

if (lavorazioni == '')you should check for:

if (lavorazioni == undefined)i didn't find declaration of this string...

Thanks for your answer, but as i said, i've declared it before this check...in fact this code works...my question was how could not lose this value outside the Ajax Request because extJS execute command line one by one, so if the request doesn't start the string remain undefined...

ashaihullin
1 Sep 2010, 6:42 AM
ok... i see what you want... but i think your way is wrong... as i understand you need to make request when previous request was finished... but you code make all requests at one moment... may be you should call some function after request end, that will make new request... smth like this...

Dark Assassin
1 Sep 2010, 11:51 PM
mmm no i've tried but i'm not too expert so i decided to do this by server side with a more complex query and let extJS do only the visualization!
Thanks for your answer anyway!

ashaihullin
1 Sep 2010, 11:54 PM
i think it is right way now... ))