我是 Sencha Touch2 的新手。从 Json 文件加载嵌套数据时遇到问题。这是我的 json 文件:
{
"html_attributions" : [
"Listings by \u003ca href=\"http://www.yellowpages.com.au/\"\u003eYellow Pages\u003c/a\u003e"
],
"results" : [
{
"geometry" : {
"location" : {
"lat" : -33.8711140,
"lng" : 151.1990420
}
},
"icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/travel_agent-71.png",
"id" : "ddd678ac0a16d83fdc25500ccb3d6aa27b7f5548",
"name" : "Darling Harbour",
"photos" : [
{
"height" : 1088,
"html_attributions" : [
"\u003ca href=\"https://plus.google.com/117001986278088134060\"\u003eStephen SteveT\u003c/a\u003e"
],
"photo_reference" : "CnRiAAAAyl02-KJEBTh19Pc4YuOhMn0DPYLCat_1HMSwX_icBwgyjWr7QGkT262oE57hMlOUypibloD1oFwxBJ8Iq3oJCLKBNXcyAmw7000P91LblItAcxuVyvltfRggSLwT36pooEmZiKITyEuwAmpKpGrxhRIQhyMbZ-cHFI6zSayNRRiH_BoUgWH-2M6mR1IO9MuftuuYkZRHUZ4",
"width" : 1600
}
],
"rating" : 4.30,
"reference" : "CnRtAAAAmNBHFs0qF9UJEw1NccjMySkm4aH3cEL6cCkLj-V4rkDJJE81-fFOar6PAtoK5d70GLJTgh_LcpysxH41iRI4hW3YreiPI66GBJYEeWA6SbgNQrJy6RbTw7LbhB6vYb3gfzpV2lE6fUtaIjx3WOLjsBIQVjFdJTUy55L1fzdzyufUaBoU194V7aIidzGbj7aRUaObJdl5GvM",
"types" : [ "travel_agency", "cafe", "restaurant", "food", "establishment" ],
"vicinity" : "Sydney"
},
{
"geometry" : {
"location" : {
"lat" : -33.870540,
"lng" : 151.1988150
}
},.........
这里可以获取图标、id、名称的数据。我跟着一个教程。但是我如何读取“lat”和“lng”的“位置”内的数据。下面是我的商店。
Ext.define('CustomList.store.StoreList', {
extend:'Ext.data.Store',
requires:['Ext.data.reader.Json','Ext.data.proxy.JsonP'],
config:{
model:'CustomList.model.ModelList',
autoLoad:'true',
proxy:{
type:'ajax',
url:'http://localhost:9091/Json/sample.json',
reader:{
type:'json',
rootProperty:'results'
}
}
}
});
这是我的模型:
Ext.define('CustomList.model.ModelList', {
extend: 'Ext.data.Model',
config: {
fields:['geometry.location.lat','geometry.location.lng']
}})
这是我的清单:ShowList.js:
Ext.define('CustomList.view.ShowList',{
extend:'Ext.Panel',
xtype:'showList',
config:{
layout:'fit',
styleHtmlContent:'true',
styleHtmlCls:'showListCls',
items:[
{
xtype:'list',
id: 'listitems',
store:'StoreList',
// itemTpl:'{id},{name},{vicinity}'
itemTpl:'{modelList.geometry.location.lat} {modelList.geometry.location.lng}'
}]
}
});
谁能帮帮我吗。谢谢。