lundi 24 mars 2014

Load Data to Form (JSON)

Hello everybody! I need your help!



I have a FormPanel in extjs 3.4 and I want to load data from seerver via a webservlet but I am a bit confused. :(



The webservlet responses with the following JSON information:

{"items":{"address":"1","email":"a@a.gr","lastname":"aaa","firstname":"olia"},"success":true}



I tried two ways:

A. After layout.setActiveItem('FormPanellID'); I

I used:

FormPanel .getForm().load({ url: 'servletURL',

failure: function(form, action) {

Ext.Msg.alert("Load failed", action.result.errorMessage);

}

});


but I get the failed message!



B. I create a new Ext.data.JsonStore

var panelStore = new Ext.data.JsonStore({ autoLoad: true,

autoDestroy: true, url : 'servletURL',

root: 'items',

fields: [' 'email', 'firstname', 'address', 'status', 'lastname', ''],

listeners : {

load: function(store, records, options){

if(records[0]){

FormPanel.getForm().loadRecord(records[0]);

} else{

console.log("no data!");

}

}

}

});




and then I call panelStore .load();

but nothing happens!



I try 5 days to load data to a form but nothing! I thought that extjs was not too difficult :(

Could you please help me?




Aucun commentaire:

Enregistrer un commentaire