PDA

View Full Version : Formpanel.load, jsonReader, mapping doesn't work ...



alberto01
26 Oct 2010, 10:27 AM
Hi at all,
I made this code:


getData: function(anag_id){
this.getForm().reader = new Ext.data.JsonReader({
root: 'data',
fields: [{
name: 'ragionesociale',
mapping:'RAGIONE_SOCIALE'
}]
});

this.getForm().load({
url: 'http://localhost/getdata.php',
params: { 'anag_id': anag_id },
waitMsg : 'Loading Data...'
});
}

and this is a part of my formpanel:


{
xtype: 'textfield',
fieldLabel: 'Ragione sociale',
name: 'ragionesociale',
allowBlank: false
},


this is my json response:


{"success":true,"data":{"ID":"83","RAGIONE_SOCIALE":"CAIO",}}


and this is the problem:

If I use "name: 'RAGIONE_SOCIALE'," in the textfiled prop instead of "name: 'ragionesociale'," it works fine.
If I use "name: 'ragionesociale'," it doesn't work, it seems that the mapping of the reader doesn't work correctly ...

any suggestion?
thanks in advance.

Alberto

raj_plays
26 Oct 2010, 12:00 PM
Change your JsonReader config to..


new Ext.data.JsonReader({
root: 'data',
Ext.data.Record.create([
{name: 'ragionesociale', mapping:'RAGIONE_SOCIALE'}
])
});

alberto01
27 Oct 2010, 1:11 AM
mm I changed the jsonreader config with:



var fitems = new Ext.data.Record.create([
{name: 'ragionesociale', mapping:'RAGIONE_SOCIALE'}
]);

this.reader = new Ext.data.JsonReader({
root: 'data',
fields: fitems
});


but it still doesn't work