2013-03-22 33 views
1

家伙让我解释一下我的问题,我有一个加载一些元素从一个存储文件列表视图,当我点击列表项,我有谁在一个新的细节推数据的控制器查看煎茶触摸TPL和项目

'placesContainer places list':{ 
      itemtap: function(list,index,target,record) { 
       console.log("item "+record.get('name')+" pigiato"); 
       var detailsView = Ext.create('MyApp.view.Details'); 
       this.getPlacesContainer().push(detailsView); 
       detailsView.setData(record.data); 

      } 
     } 

确定这里。现在我想要的是在我的新“详细信息”视图中从商店文件中加载相同的信息。 这里是我的局部视图:

Ext.define('MyApp.view.Details',{ 
extend:'Ext.Panel', 
xtype:'details', 
config:{ 
    layout:'vbox', 
    scrollable:true, 
    styleHtmlContent:true, 
    styleHtmlCls:'details', 
    tpl:'<h1>{name}</h1>' + 
     '<p><span>Lunghezza:</span> {lunghezza} <span>Difficoltà:</span> {difficulty}</p>' + 
     '<h2>{prova}</h2>', 
    items: [ 
     { 
      xtype: 'panel', 
      flex:1, 
      store:'Places', 
     }, 
     { 
      xtype: 'carousel', 
      flex:2, 
      items: [ 
       {style: "background-color: #7BB300"}, 
       {style: "background-color: #555555"}, 
       {style: "background-color: #00ff2a"}, 
       {style: "background-color: #00bb1f"}, 
       {style: "background-color: #008616"}, 
       {style: "background-color: #00490c"} 
      ] 
     } 
    ] 
} 

如果我写OUTSIDE项目TPL的元素,我可以读出的数据在我的详细信息视图。当我尝试把tpl元素内的项目,所有的数据消失..有什么问题? 我试过这种方式,但没有结果...

items: [ 
     { 
      xtype: 'panel', 
      flex:1, 
      store:'Places', 
      tpl:'<h1>{name}</h1>' + 
       '<p><span>Lunghezza:</span> {lunghezza} <span>Difficoltà:</span> {difficulty}</p>' + 
       '<h2>{prova}</h2>', 
     }, 
items: [ 
     { 
      xtype: 'panel', 
      flex:1, 
      store:'Places', 
      itemTpl:'<h1>{name}</h1>' + 
       '<p><span>Lunghezza:</span> {lunghezza} <span>Difficoltà:</span> {difficulty}</p>' + 
       '<h2>{prova}</h2>', 

     }, 

的帮助将是巨大的!

+0

没有试过,但是你可能需要实际调用'使用setData()'两个孩子'Panel's的为好。 – jprofitt 2013-03-22 12:12:00

+0

在子面板中添加'setData()'是什么意思? – 2013-03-22 12:21:36

+0

你在'items'中有两个'Panel's。用同样的方法你打电话'使用setData()'的'detailsView',但对这些孩子,而不是在'detailsView'本身(或可能除了,这取决于你已经改变了它)。 – jprofitt 2013-03-22 12:41:08

回答

3

你需要让你liitle变化itemtap功能

'placesContainer places list':{ 
     itemtap: function(list,index,target,record) { 
      console.log("item "+record.get('name')+" pigiato"); 
      var detailsView = Ext.create('MyApp.view.Details'); 
      this.getPlacesContainer().push(detailsView); 
      detailsView.setData(record.data); // will set data to detailsview 

      detailsView.getAt(0).setData(record.data); // will set data to first component in items array 

      detailsView.getAt(1).setData(record.data); // will set data to second component in items array 

       .... and so .... 

     } 
    } 
+0

谢谢你,你让我的一天,新的'itemtap'功能它的工作!现在我将我的商店数据放入我的第一个项目面板中。顺便说一下,我不明白'detailsView.getAt(1)'做了什么。在sencha编程中,我是一个新手,并且在JavaScript编程方面都是如此。这个功能让我可以从我的'items'中访问我的商店数据?指数的数字是什么意思?谢谢! – 2013-03-22 14:16:18

+0

'getAt()'方法从容器的'items'数组返回组件。 'items'是分量的数组所以'getAt(0)'将返回出'items'阵列和getAt(1)将第二reutrn元件的第一元件。 – SachinGutte 2013-03-22 15:08:56

+0

所以我甚至可以从我的'itemtap'功能设定我的详细信息视图'title'直接? – 2013-03-22 15:14:36