Form and JSON reader
I just tried to populate a form with a JSON string generated with PHP.
Here is my JS code :
Ext.onReady(function(){
var myRecord = new Ext.data.Record.create([
{name:'nomchamp'},
{name:'typechamp'}
]);
var myReader = new Ext.data.JsonReader({
successProperty: 'success',
totalProperty: 'results',
root: 'champs',
id: 'nomchamp'
}, myRecord);
var fs = new Ext.FormPanel({
frame: true,
defaultType: 'textfield',
reader: myReader,
items: [{
fieldLabel: 'Nom',
name: 'nomchamp',
}, {
fieldLabel: 'Type',
name: 'typechamp',
}]
});
fs.addButton('Load', function(){
fs.getForm().load({url:'json-form.php', waitMsg:'Loading'});
});
fs.render('form-ct');
});
and my PHP code
$StrJSON = '{"success":"true","results":"1","champs":{"nomchamp":"Nom", "typechamp":"Type"}}';
print $StrJSON;
but my fields remain blank after a click on the load button.
Could you help me ???
Thanks a lot for your help.
http://extjs.com/learn/Ext_FAQ_Forms
Do not use a Reader with a form. Forms understand JSON.
http://extjs.com/deploy/dev/docs/?class=Ext.form.Action.Load
http://extjs.com/deploy/dev/docs/?class=Ext.form.Action.Submit
#If you have any other info about this subject , Please add it free.# |