PDA

View Full Version : Issue with loading form panel with nested json response



vsrinivasprasad
14 Jan 2012, 2:19 PM
Need your help. I m new to ExtJs, i m unable to load fields like person.address.city into extjs. I can see fields like recordNumber gets loaded with out issue. Could you please tell me what needs to be done.

{"data":{"recordNumber":2121211,"depositoryName":"John Doe","ourAccount":true,"b
ankAccountDetailList":[{"nameIfNtBorrwer":"TESTER - 1","bankAccountDetailsID":1,
"balence":5000.0,"bankAccountNum":1000,"bankAccountType":"Checking"},{"nameIfNtB
orrwer":"TESTER - 2","bankAccountDetailsID":2,"balence":10000.0,"bankAccountNum"
:2000,"bankAccountType":"Saving"}],"id":1,"address":{"street":"1898 S Clinton St
","city":"Chicago","zip":"60607","state":"IL"}},"success":true}

function fnLoadForm(theForm)
{
theForm.getForm().load({


url: 'loadbankaccount.html',


headers: {Accept: 'application/json, text/javascript, */*; q=0.01'},


waitMsg: 'loading...',


params : {


id: 1


}
});




} //end

mitchellsimoens
15 Jan 2012, 2:18 PM
Ext JS 3 or 4?

vsrinivasprasad
17 Jan 2012, 7:35 AM
I m using extjs 4, please help me. Thx

mitchellsimoens
17 Jan 2012, 7:36 AM
I have moved this thread to the appropriate forum, Ext JS 4 Q&A forum. Please post in the appropriate forum and wrap your code in code tags.

friend
17 Jan 2012, 7:48 AM
A form's load() method isn't intended for loading nested data structures. Basically, there should be a one-to-one correspondence between each component in your form and each item in the data attribute of the JSON.

You can manually extract the nested data bits and set values on specific components in the success method of the form load:



someForm.load({
url: 'employee/get',
params: {
employeeId: 1
},
success: function(basicForm, action) {
someOtherFormComponent.setValue(action.result.data.some.nested.property);
},
failure: function(basicForm, action) {
// do somethng on failure.
}
});