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"
}]
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"
}]
相关文章推荐
- Ext.data-GroupingStore/JsonStore/SimpleStore
- Ext.data.Store/GroupingStore/JsonStore/SimpleStore
- Getting Started with Sencha Touch 2
- SAP传输停止错误:Test call of transport control program (tp) ended with return code 0208!
- 第二周第五天(enum/HashMap/HashSet/IteratorArryList/Data/Calendar/SimpleDateFormat/JSON的生成和解析)
- Ext.data-GroupingStore/JsonStore/SimpleStore
- Creating & Parsing JSON data with Java Servlet/Struts/JSP
- no data exchange control with ID的解决方法
- sencha touch carousel 扩展 CardList 可绑定data/store
- SAP传输停止错误:Test call of transport control program (tp) ended with return code 0208!
- Sencha学习笔记1: Getting Started with Sencha Touch - 官方Sencha Touch入门指南
- Sencha Touch 2 官方文档翻译之 Intro to Applications with Sencha Touch 2(ST2应用程序简介)[转]
- Sample: Write And Read data from HDFS with java API
- Preloading Data with Ajax and JSON
- Android doc译文|Building Apps with Content Sharing|Sharing Simple Data
- WTL Application Develop Use CListViewCtrl Control With LVS_OWNERDATA Style (virtual ListCtrl)
- SQL to JSON Data Modeling with Hackolade
- SyntaxError: JSON.parse: bad control character in string literal at line 1 column 16 of the JSON data
- Binding Data With TreeView Control ASP.NET 2.0
- Sencha Touch 2 官方文档翻译之 Intro to Applications with Sencha Touch 2(ST2应用程序简介)