PDA

View Full Version : Create Extjs Components from JSON



john_tadros
21 Feb 2012, 8:45 AM
Hi All,

I want to create a Panel from a response from a certain server-side server.
Meaning, I have some REST Webservice that when called with some parameter, will return to to me a form with 2 text fields, if called with some other value for that parameter, will return a form with 1 text field and 1 combobox

One option I have is to return plain HTML from the server and just display it, but this is not the best way of doing it.

So I recall seeing somewhere a piece of code that parses JSON and transforms it to a panel, can someone help me with that ?

Regards
John

mitchellsimoens
21 Feb 2012, 11:22 AM
Why not return a JSON object that is a config object... so return


{
"items" : [
{
"xtype" : "textfield",
"fieldLabel" : "Test"
}
]
}

Then you can decode it and create a form from it.

john_tadros
22 Feb 2012, 11:03 AM
Thanks for your reply. That worked great.