PDA

View Full Version : How to retrieve data nd show that in the basic form



sajan
13 Jul 2010, 2:37 AM
Dear All,
I am stuck on basic form. I have one window with tab panel. So First tab has basic form fields like text box and combo.

I am stuck in retrieving the data. (Do I have to create a JSON store?. cause I don't think I have to cause it is only a single record. Can I retrieve those fields as parameters?)
How to load data into those form fields. I am sure I have set value field but how to do that I am completely clue less?
please help me.
thank you

jarrednicholls
13 Jul 2010, 6:47 AM
Hi sajan,

You do not need a store to load data into the FormPanel/BasicForm. There is a method "load" (http://www.sencha.com/deploy/dev/docs/?class=Ext.form.BasicForm&member=load, see also "doAction" for the options available) that can do an Ajax call to your server and pull back a JSON response and load that into the form fields automatically by matching up the configured "name" of each field.

Example:


myForm.load({
url: '/users/1',
success: function(form, action){
alert('Form data loaded successfully!');
},
failure: function(form, action){
alert('Something went wrong...');
}
});


A "load" operation expects a particular response in order to understand whether the request was successful or not. See http://www.sencha.com/deploy/dev/docs/?class=Ext.form.Action.Load and read the top comments to see what an example of a successful or unsuccessful response would be...

success:


{
success: true,
data: {
clientName: "Fred. Olsen Lines",
portOfLoading: "FXT",
portOfDischarge: "OSL"
}
}


failure:


{
success: false
}


If the server responds with something other than HTTP OK (200), then the result will be a failure automatically.

Let me know if that helps. Be sure to check into the Ext JS API documentation every now and then, there is a lot of good information.