您的位置:首页 > Web前端 > JavaScript

a simple sample return json data with sencha touch control

2011-11-04 10:52 495 查看
index.js

Ext.setup({
onReady: function() {

Ext.regModel('Person', {
fields: [
{name: 'id', type: 'string'},
{name: 'name', type: 'string'}
]
});

//I want the name to be written on the page
var itemTemplate = new Ext.XTemplate(
'<tpl for=".">',
'{name}',
'</tpl>');

// I get and decode the Json from data.json
var jsonStore = new Ext.data.Store({
model: "Person",
proxy: {
type: 'ajax',
url: 'data.json',
reader: {
type: 'json'
}
},
autoLoad: true
});

// The panel should get the stored Result and display it

var jsonPanel = new Ext.Panel ({
title: "json",
fullscreen: true,
items: [
{
xtype: 'list',
store: jsonStore,
itemTpl:itemTemplate
}
]
});

}
});

json data
[{
"id": "0",
"name":"myname"
}, {
"id": "1",
"name":"myname2"
}]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息