PDA

View Full Version : Need some help with Form and AJAX call.



Elijah
7 Apr 2010, 12:07 PM
var myFormData = "";
Ext.Ajax.request({
url:'api.jsp' (http://www.extjs.com/forum/'api.jsp'),
success: function(response, options){
var obj = Ext.decode(response, responseText);
myFormData = obj.data;
} // ...(omitting the failure for now)
}); // Ajax.request


using a dump of the data I can see the data from the request so I have the information that I want.

The problem that I have is that I am unable to set any form data. So, how can I set the data in my form.

// some code ommited to shorten this post.
var tempF = new Ext.FormPanel({
id:'myProfile',
title:'My Profile',
items:[{
layout:'column',
border:false,
items:[{
xtype:'textfield',
layout:'form',
fieldLabel:'First Name',
name:'firstName',
allowBlank:false
}]
}]
}); //


Trying to populate the form field firstName with


tempF.getForm().getComponen('firstName').value = myFormData.firstName;


Please assist with code syntax correction and not telling me to reference the API. I have been reading over the API all darn day.

cog
7 Apr 2010, 12:40 PM
if you want to set the value of e.g. firstname you should write:

Ext.getCmp('firstname').setValue(response.root_of_your_array.data_field_name);

hth

fay
7 Apr 2010, 12:44 PM
and not telling me to reference the API.

Really sorry about this... always think of JS code as having specific "value" getter and setter methods - that will change the underlying value - and not trying to directly reference the "value" config option itself... so see setValue in the API! (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.TextField&member=setValue)

Elijah
7 Apr 2010, 4:32 PM
So is most of ExtJS built with the notion of using getters() and setters() if so that would be awesome.

jarlau
7 Apr 2010, 10:44 PM
[CODE]
not telling me to reference the API. I have been reading over the API all darn day.


this (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Action.Load) api should be better for you.