Extjs 如何在模型中引用复杂的json对象,以便它们可以显示在列表中

Extjs 如何在模型中引用复杂的json对象,以便它们可以显示在列表中,extjs,sencha-touch,sencha-touch-2,Extjs,Sencha Touch,Sencha Touch 2,我试图在我的模型中引用复杂的json对象,然后将它们与另一个对象一起显示在表中。下面是json的一个示例。如何获得评级和类型 "reviews" : [ { "aspects" : [ { "rating" : 1, "type" : "food" }, { "rating" : 3, "

我试图在我的模型中引用复杂的json对象,然后将它们与另一个对象一起显示在表中。下面是json的一个示例。如何获得评级和类型

   "reviews" : [
     {
        "aspects" : [
           {
              "rating" : 1,
              "type" : "food"
           },
           {
              "rating" : 3,
              "type" : "decor"
           },
           {
              "rating" : 2,
              "type" : "service"
           }
        ]


Ext.define('FirstApp.model.Details',{
extend:'Ext.data.Model',
config:{
  //  fields:     ['id','recordId','name','icon','vicinity','reference','website','reviews.aspects.type'],


 fields: [ {

name: 'aspects',
mapping: 'reviews.aspects'
},
  {
  name: 'vicinity'
  },
    {
   name: 'name'
  },
  {
  name: 'icon'
  },
 {
  name: 'website'
  }]

  }
  })
我正在调用下表,但是我得到了错误Uncaught SyntaxError:在itemTpl所在的位置意外标记非法

             {
              xtype:'list',
              store:'Details',
                itemTpl:'<img src="{icon}"></img><h1>{name:ellipsis(25)}</h1>
                <h3>{vicinity:ellipsis(35)}</h3><h2>{website}</2><h2>{reviews}</h2><tpl   for="aspects">
               {rating} - {type}
              </tpl>',
            itemCls:'place-entry'
           }
样本数据:

      "reviews" : [
        {
        "aspects" : [
           {
              "rating" : 3,
              "type" : "food"
           },
           {
              "rating" : 3,
              "type" : "decor"
           },
           {
              "rating" : 3,
              "type" : "service"
           }
        ],
        "author_name" : "Aubrey Skelly",
        "author_url" : "https://plus.google.com/101776084849290882399",
        "text" : "Small and wonderful, the food fantastic, service 100% miss this    wonderful restaurant and you will miss a gem in waterford",
        "time" : 1359588944
     },

我认为您必须在模型中映射:

fields: [
{
    name: 'aspects',
    mapping: 'reviews.aspects'
},
{
    name: 'vicinity'
}
...
第三方物流:

<tpl for="aspects">
    {rating} - {type}
</tpl>

{rating}-{type}
注: tpl中不能有换行符:

//this will throw an error
itemTpl: '<div>this is some content<br>
         this is the same div but I am on a new line now</div>'
//这将抛出一个错误
itemTpl:'这是一些内容
这是同一个部门,但我现在在新的线路上'
您必须拆分行:

//this is OK
itemTpl: '<div>this is some content<br>',
         'this is the same div but I am on a new line now</div>'       
//这没问题
itemTpl:“这是一些内容
”, '这是同一个部门,但我现在在新的线路上'
您好,我已尝试了您的解决方案,但在声明表时出现以下错误。我已经更新了上面的代码,以显示我在哪里得到的错误你不能在第三方物流线中断。我在答案上加了一条注释。请检查一下。嗨,我在代码中添加了一个注释。错误现在消失了,但子对象仍然不显示。我看过一个json,以确保它们在里面,它们在里面。你们能发布一个数据样本吗?嗨,我在我的原始问题中发布了一个json样本
//this will throw an error
itemTpl: '<div>this is some content<br>
         this is the same div but I am on a new line now</div>'
//this is OK
itemTpl: '<div>this is some content<br>',
         'this is the same div but I am on a new line now</div>'