PDA

View Full Version : How can I load data in a form, without an event ?



gianalesigi
12 May 2010, 5:36 AM
How can I load data in a form, without an event ?
I open an Ext.Window with an Ext.FormPanel and want to load the data from an request directly.
Anyone knows how to make the easiest?
Thanks & greetings

CrazyEnigma
12 May 2010, 6:15 AM
Why wouldn't you? You don't know exactly when the data is coming in so you need to provide a callback to process the data after the request has completed. If you already have the data, then use load().

fay
12 May 2010, 6:19 AM
Not certain what you mean by without an event? You don't want to use the load (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Action.Load) method? Take a look at loadRecord (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.BasicForm&member=loadRecord) instead.

Mike Robinson
12 May 2010, 6:28 AM
loadRecord, which is actually a method of BasicForm (and documented there), is undoubtedly what you are looking for here.

gianalesigi
12 May 2010, 6:50 AM
Thanks for answers.
When i use:
this.load({
url: '/json/getdata'
});

and this url send the data like this:
exit(json_encode(array('data'=>$aData))); // $aData is an array()

instead of the formular with the data,
it's loaded this:
{"data":{"name":"firstname","middle_name":"middlename","last_name":"lastname"}}

Animal
12 May 2010, 7:26 AM
Read the API docs. They tell you exactly what the JSON must look like from a load request.