PDA

View Full Version : Getting and showing the id record after formīs submission



mvosantos
2 May 2012, 9:53 AM
Hello guys.
I have a formpanel with a data inserting working.
I would like to know whether I can get the Id after the form submission, binding the store with the new id and display it to user.
Iīve already returned the data in my json, like the json below but my store is not getting the new values.
What am I doing wrong?
{"success":true,"reason":"Registro salvo com sucesso","data": {"idusuario":"1","idcliente":1,"os":"","dt_os":"","idprodutor":3,"idexportador":1,"idterminal":4,"iddespachante":0,"idcorretor":0,"idtrader":0,"idcidade":1,"idcondicoes":0,"idnavio":0,"situcao":"","viagem":"","deaddox":"","deadcargo":"","qtde_full":"","qtde_part":"","contrato":"","booking":",","dt_envio_peso":null,"dt_envio_draft":null,"dt_finalizado":null,"dt_pago":null,"destino":"","observacao":"","dt_fat":null,"cotacao":"","desconto":"","nf":"","observacao_fat":"","safra":"2012","ie":"BRZ3445","taxa":"","unidade":"","moeda":"","peso":"","limite_min":"","limite_max":"","limite_cntr":"","qtde_fardos":"359","dt_certificado":null,"titulo":"","dt_termino_servico":null,"tipo_limite":"","integrada":"","arquivo_integracao":"","idos":"8"}}

scottmartin
2 May 2012, 11:55 AM
You can do something like:



myForm.getForm().submit({
params: {},
success: function(form, action) {
console.log(action); // display result object
},
failure: function(form, action) {
}
});


Then you can use form.loadRecord(record) to load the updated data back into the form.

Regards,
Scott

mvosantos
2 May 2012, 12:22 PM
Actually I wanna get the values after calling the storeīs method sync().
Iīm able to get the new data from the "write listener", but how can I get this on controller to set all the new values to my form?

this is the storeīs listener:


listeners : {
write: function(proxy, operation){
var obj = Ext.decode(operation.response.responseText);
console.log(obj.data);
if(obj.success){
...
}....
}

I can see the new values on my console.log(obj.data), but I want to get it on the controller to apply the form.loadRecord or the form.setValues to my form.