PDA

View Full Version : Variables json - extjs



john31
24 May 2011, 10:17 AM
Hi everyone
I'm beginner with Extjs and can't solved this problem...
I wanted to get back the Json values into new variables.
My Json looks like :


"info:[{"0":"Micheal","firstname":"Micheal","1":"Dubois","lastname":"Dubois","2":"21","age":"21"}]


Here is my store :


var infostore = new Ext.data.JsonStore({
url: 'connectpostgres.php',
root:'info',
id:'info' ,
fields: [
{name:'firstname'}
,{name:'lastname'}
,{name:'age'}

]
});
infostore.load();


And now I want to display the values here into a Panel (not a grid):


var resultats= new Ext.FormPanel({
labelWidth: 50,
frame:true,
bodyStyle:'padding:5px 5px 0',
width: 230,
items:
[{
xtype: 'label',
fieldLabel: 'firstname',
text: ?????
},{
.....


I don't know how to give the value 'firstname' to text: ??? :-?

Thanks a lot for your help

friend
25 May 2011, 10:43 AM
Rather than use a JsonStore, why not just issue an Ajax request?



Ext.Ajax.request({
url: 'someUrl',
params: {
someParam: 'someValue'
},
method: 'POST',
success: function(result, request) {
var json = Ext.decode(result.responseText);
Ext.Msg.alert('JSON Data', 'First Name is: ' + json.info.firstName);
},
failure: function(result, request) {
Ext.Msg.alert('Error', 'An Error has bitten ye squarely on the keister...');
}
});

john31
26 May 2011, 11:43 AM
Yes you're right, it's a better idea!
Thank you for your time and help