View Full Version : loading one record from table into a form with php/json

kurt schrauwen
3 Dec 2010, 12:21 PM

I'm trying to load one record from a table into a form with php/json but I'm not succeeding.
Can anyone point me in the right direction please.

I can load one paricular record in the form if I give the ID harcoded, but I want to make this dynamic


3 Dec 2010, 12:48 PM
In hope that I understand what you're trying to do:

Ext.form.BasicForm contains a loadRecord(record) method, which will let you load a desired record from a store directly into the owning Ext.form.FormPanel.

var selectedRecord = someGrid.selModel.getSelected();
Any form field with a name attribute that matches a record field will be auto-populated from the record.

If I've misunderstood your problem, please reply accordingly.


3 Dec 2010, 3:08 PM
Now imagine you have an XHTML Response Object...Just decode the responseText and pass the result to BasicForm.setValues?

x: 12,
y: '123',
z: 'foobar'

kurt schrauwen
3 Dec 2010, 3:38 PM
Hai Screamy,

Actualy my problem is the datasore itself
I want to load my datastore with the desired record

I'm trying to do this with the Ext.data.JsonReader

but so far no luck

5 Dec 2010, 6:49 AM
The Ext.data.Store documentation has the solution you're looking for, I think:

Records are cached and made available through accessor functions. An example of adding a record to the store:
var defaultData = {
fullname: 'Full Name',
first: 'First Name'
var recId = 100; // provide unique id for the record
var r = new myStore.recordType(defaultData, ++recId); // create new record
myStore.insert (http://webserver/ext/docs/output/Ext.data.Store.html#Ext.data.Store-insert)(0, r); // insert a new record into the store (also see add (http://webserver/ext/docs/output/Ext.data.Store.html#Ext.data.Store-add))

Is this what you're after?

kurt schrauwen
5 Dec 2010, 11:28 PM
Hai Screamy,

Yes that was it, thanks for your help en info.