View Full Version : Get form layout from server

Jelmer Baas
18 Jan 2010, 3:50 AM
Hello everyone,

When I open a form in a new panel, I want to retrieve the form layout (i.e. the fields in the forms and their names) from the server. I don't much care how (via JSON, XML, etc).

After much searching I found an old extension called ServerForm, but that's for ExtJS 1.0.

Can anyone tell me how I could accomplish this? Is there perhaps an updated extension available?

If this message is too vague, please let me know.

Thanks for any help.


18 Jan 2010, 5:07 AM
You can try sending an array of Ext.form.Field configuration objects and adding them all to the form. (don't forget to doLayout)

Jelmer Baas
18 Jan 2010, 5:18 AM
Thanks for the response. That does sound more-or-less what I need. Could you perhaps give me a push in the right direction how to implement this? I'm still struggling to understand ExtJS.

18 Jan 2010, 5:38 AM
You make your server send a response to you request like:

succes: true,
data: [{
xtype: 'textfield',
name: 'field-one',
fieldLabel: 'Field One'
xtype: 'textfield',
name: 'field-two',
fieldLabel: 'Field Two'

JSON decode the response and iterate over the data array. for each item in the array do:
finally call form.doLayout() to display the new items.

Also: read the API for Ext.Ajax.request and Ext.form.FormPanel.add

Jelmer Baas
19 Jan 2010, 1:00 AM
Thanks! I solved it by doing this:

var testconn = new Ext.data.Connection();
url: 'content.asp',
method: 'post',
params: {'id': record.data['id']},
success: function(responseObject) {
try {
var jsonData = Ext.util.JSON.decode(responseObject.responseText);
for (var i = 0; i < jsonData.data.length; i++) {

... etc ...

This works like a charm :)