PDA

View Full Version : no data in formpanel



noimehl
23 Dec 2010, 6:45 AM
Hi,

i have a new formpanel. after loading the data, they will not be displayed in the formpanel.
Here is my code:



MyPanel2Ui = Ext.extend(Ext.FormPanel, {
id: 'MyPanel2UiID',
title: 'Tab 3',
layout: 'form',
frame: true,
initComponent: function() {
this.items = [
{
id:'anr',
xtype: 'displayfield',
fieldLabel: 'Field A',
name: 'anr',
anchor: '95%'
},
{
xtype: 'displayfield',
fieldLabel: 'FIELD B',
name: 'id',
anchor: '100%'
},
{
xtype: 'displayfield',
fieldLabel: 'FIELD C',
name: 'sponsor',
anchor: '100%'
}
];
MyPanel2Ui.superclass.initComponent.call(this);

this.on({
render: {scope: this, fn: function(){
Ext.getCmp('MyPanel2UiID').getForm().load({
url:'data/json-propdata.php',
params:{xaction: 'read', propID: 1},
waitMsg: 'Loading...',
loadMask: true
})
} }
});
}
});
And the recieved data:


{success: true, data: [{'anr':'123-45-ABC','id':1718,'sponsor':'Cats - Dogs Ltd.'}]}
Can someone explain my why? And support my to find a solution?

Condor
23 Dec 2010, 7:05 AM
This JSON data doesn't match the expected format.

Either change the JSON data ('data' should be an object and not an array) or specify a 'reader' in the form to handle this kind of data.

noimehl
23 Dec 2010, 12:07 PM
Now i have changed the JSON fomat to


{"success":true,"data":[{"angebotsnummer":"378-09-REACh.1","id":"1124","sponsor":"BRUNO BOCK "}]}

but the result ist the same. Now i will try an arrayreader.

noimehl
23 Dec 2010, 12:40 PM
i solved the problem. it was a wrong JSON format, but JSONlint has validated my result.

the right JSON format is



{'success':'true','data':{'anr':'123-45-ABC','id':1718,'sponsor':'Cats - Dogs Ltd.'}}