Sencha Touch2를 처음 사용합니다. Json 파일에서 중첩 된 데이터를로드하는 중 문제가 발생했습니다. 이 내 JSON 파일입니다Sencha Touch2 : 상점에서 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'의 '위치'안의 데이터를 읽을 수 있습니까? 아래는 내 가게입니다. 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}'
}]
}
});
어느 한 도와 주실 래요
Ext.define('CustomList.model.ModelList', {
extend: 'Ext.data.Model',
config: {
fields:['geometry.location.lat','geometry.location.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'
}
}
}
});
이
내 모델입니다. 감사. 당신이rootProperty
geometry
에를 설정하는 코드에서
documentation
rootProperty : String The name of the property which contains the Array of row objects. For JSON reader it's dot-separated list of property names.
에서
을하는 데 도움이 제안했지만 오류가 발생했습니다. 나는 코드를 업데이트하고 참조를 위해 showList.js를 추가했다. 감사. – chipmunk
rootProperty : 'results.geometry.location'은 rootProperty 여야합니다. 'results'및 입력란 : [ 'lat', 'lng'] 필드 여야합니다. [ 'geometry'] –
[Ext.XTemplate # apply] 오류 : 정의되지 않은 '지오메트리'속성을 읽을 수 없습니다. 코드를 업데이트 할 수 있습니까? 감사. – chipmunk