The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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.