PDA

View Full Version : Load json data to form (callback )



navvn
15 Dec 2010, 4:06 AM
Hello,

I have an action on a rowselect to fill my form with JSON data.



var myMask = new Ext.LoadMask(Ext.get('companyFirPreview'), {msg:"Prosz? czeka?, trwa wczytywanie danych..."});
myMask.show();
var companyJsonId = record.get('com_id');
jQuery.getJSON('/companies/getcompany/id/'+companyJsonId, function(data) {
if(data.success == true){
companyCardForm.getForm().load({
url:'/companies/getcompany',
params:{
id: companyJsonId
}
});
myMask.hide();
}
else {
Ext.Msg.show({
title: 'Uwaga!',
msg: 'Wyst?pi? b?ad.<br />Komunikat: '+data.errormsg+'<br />Numer b??du: '+data.errorcode+'',
icon: Ext.MessageBox.ERROR,
buttons: Ext.MessageBox.OK
});
myMask.hide();
}
});


Now i have 2 queries to server, from extjs and jquery. Is there a callback method in from.load() i could use? Like one when submiting form:
success:
failure:

regards

arthurakay
15 Dec 2010, 6:16 AM
Look at the API docs.

FormPanel has the load() method:


This is a proxy for the underlying BasicForm's Ext.form.BasicForm.load call.

Parameters:
options : Object
The options to pass to the action (see Ext.form.BasicForm.doAction for details)
Returns:
void


Following the link takes you here:
- http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Action.Load?class=Ext.form.Action.Load

You'll see the config options for calling load() - which include "failure" and "success"

navvn
15 Dec 2010, 6:18 AM
thank you very much

christian130
15 Dec 2010, 7:00 AM
yes it have, when fetching the records from a store u cal call into the store.load parameter callback for example:
store.load({params:{x:'ss'}
callback: function(){
// here u can pick up all the records when the store finally is loaded
}
});

navvn
15 Dec 2010, 11:01 PM
Cheers, finally it look like this:


companyCardForm.getForm().load({
url:'/companies/getcompany',
params:{
id: companyJsonId
},
failure: function(form, action) {
Ext.Msg.show({
title: 'Uwaga!',
msg: 'Wyst?pi? b?ad.<br />Komunikat: '+data.errormsg+'<br />Numer b??du: '+data.errorcode+'',
icon: Ext.MessageBox.ERROR,
buttons: Ext.MessageBox.OK
});
myMask.hide();
},
success: function(form, action) {
myMask.hide();
}
});
and works as intended.

Regards