JForestor (5) [Avatar] Offline
#1
I'm attempting to create a simple form utilizing dataStore. Can someone tell me why the code isn't working? Thanks. Here is my code:


Ext.regModel('person', {
fields :
[
'name',
'pID'
]
});

var peopleStore = new Ext.data.JsonStore({
model: 'person',
proxy:
{
type : 'ajax',
url: 'getPersons.json',
reader:
{
type: 'json',
root: 'data'
},
idProperty: 'pID'
},
autoLoad : true
});


var myPanel = new Ext.form.FormPanel({
fullscreen : true,
dockedItems:
[
{
xtype : 'toolbar',
title : 'Tell us about yourself.',
dock : 'top'
}
],
items:
[
{
xtype: 'selectfield',
label: 'Select',
valueField: 'pID',
displayField: 'name',
store: peopleStore
}
]
});


And here is the JSON file:

{
success: true,
data:
[
{ name: "Anthony De Moss", pID: 1 },
{ name: "Jay Garcia", pID: 2 }
]

}
JvrBaena (1) [Avatar] Offline
#2
Re: Example on 141 not working
The json is not valid, it should be:


{
"success": "true",
"data": [
{ "name": "Anthony De Moss", "pID": "1" },
{ "name": "Jay Garcia", "pID": "2" }
]

}


Also, you need to provide a name for the selectField or you will get another error. name:"selectField" should do the job smilie
PraKadam (1) [Avatar] Offline
#3
Re: Example on 141 not working
Even though I made the changed as you have mentioned, it is still not working for me.