PDA

View Full Version : Combobox async problem



lguzman
17 Sep 2010, 10:06 AM
Hi everyone.

I have a problem with my combobox, when an item is select, the select event fires up an make a call to my database, after that i need to apply a filter to a datagrid (repopulate it) but since javascript make asyncronus calls, i haven't got the answer from my combobox event and the grid try to repopulate himself.

this is my code


listeners: {
select: function(f,r,i){
Ext.Ajax.request({
url:'Presupuesto.jsp',
method: 'POST',
params: {
task: "4",
Filtro: i}
}),
store.load({
callback: function(){
Ext.Msg.show({
title: 'Carga completa',
msg: 'La informacion se ha cargado con exito.',
modal: false,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
})
}
})
}
}

Is there any way to start the "store.load" event after the Ext.Ajax.request() have finish?

Thanks in advance

troseberry
17 Sep 2010, 11:23 AM
apply a callback on the Ajax.request method. If you look at the api doc on the request method under Ext.Ajax it will show you the parameters of the method and you can specify either a success, failure, or callback that will call no matter what status.

lguzman
17 Sep 2010, 11:53 AM
Ok i have more reading to do, your comment solve my problem and my code looks like this now:


listeners: {
select: function(f,r,i){
Ext.Ajax.request({
url:'Presupuesto.jsp',
method: 'POST',
params: {
task: "4",
Filtro: i},
success: function (){
store.load({
callback: function(){
Ext.Msg.show({
title: 'Carga completa',
msg: 'La informacion se ha cargado con exito.',
modal: false,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
})
}
})
}
})
}
}

Thanks