I'm very new to Sencha touch. I have to Load JSON data in a list.
My Panel.js
Ext.define('MyApp.view.MyPanel', {
extend: 'Ext.Panel',
requires: [
'Ext.Toolbar',
'Ext.dataview.List',
'Ext.XTemplate'],
config: {
items: [{
xtype: 'toolbar',
docked: 'top',
title: 'Test'
}, {
xtype: 'list',
itemTpl: [
'\'<tpl for="polls">\',',
' \'<div> {title}</div>\',',
' \'<div> {uri}</div>\',',
'\'</tpl>\','],
store: 'MyStore'
}]
}
});
MyModel.js
Ext.define('MyApp.model.MyModel', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.Field',
'Ext.data.proxy.JsonP'],
config: {
fields: [{
name: 'title'
}, {
name: 'uri'
}]
}
});
MyStore.js
Ext.define('MyApp.store.MyStore', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.MyModel',
'Ext.data.proxy.JsonP',
'Ext.data.reader.Json'],
config: {
autoLoad: true,
model: 'MyApp.model.MyModel',
storeId: 'MyStore',
proxy: {
type: 'jsonp',
url: 'my_web_site_url/polls',
reader: {
type: 'json',
rootProperty: 'polls'
}
}
}
});
The JSON FILE has the following format..
{
"polls": [
{
"title": "how r u?",
"uri": "/polls/answer1"
}
]
}
and my_web_site_url/polls/uri
will give u the
{
"choices": [
{
"choice": "fine",
"votes": 0
},
{
"choice": "good",
"votes": 0
},
{
"choice": "sad",
"votes": 0
}
],
"title": "how r u?",
"uri": "/polls/answers1"
}
When I try 'Load Data' in the Sencha Architect it shows:
Unable to load the data Using the supplied Configuration open in Browser my_website_url/polls