2013-03-22 74 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