Javascript Sencha Touch第三方物流和项目

Javascript Sencha Touch第三方物流和项目,javascript,sencha-touch,sencha-touch-2,Javascript,Sencha Touch,Sencha Touch 2,伙计们,让我来解释我的问题,我有一个列表视图,可以从存储文件中加载一些元素,当我单击列表项时,我有一个控制器,可以将数据推送到一个新的详细视图中 'placesContainer places list':{ itemtap: function(list,index,target,record) { console.log("item "+record.get('name')+" pigiato");

伙计们,让我来解释我的问题,我有一个列表视图,可以从存储文件中加载一些元素,当我单击列表项时,我有一个控制器,可以将数据推送到一个新的详细视图中

'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"}
            ]
        }
    ]
}
Ext.define('MyApp.view.Details'{
扩展:'Ext.Panel',
xtype:“详细信息”,
配置:{
布局:'vbox',
可滚动:对,
styleHtmlContent:对,
styleHtmlCls:“详细信息”,
tpl:“{name}”+
“Lunghezza:{Lunghezza}困难:{Difficolt}

”+ “{prova}”, 项目:[ { xtype:'面板', 弹性:1, 商店:'地方', }, { xtype:'旋转木马', 弹性:2, 项目:[ {风格:“背景色:#7BB300”}, {风格:“背景色:#555555”}, {风格:“背景色:#00ff2a”}, {样式:“背景色:#00bb1f”}, {风格:“背景色:#008616”}, {样式:“背景色:#00490c”} ] } ] }
如果我在项目外部写入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>',

        },
项目:[
{
xtype:'面板',
弹性:1,
商店:'地方',
tpl:“{name}”+
“Lunghezza:{Lunghezza}困难:{Difficolt}

”+ “{prova}”, }, 项目:[ { xtype:'面板', 弹性:1, 商店:'地方', itemTpl:“{name}”+ “Lunghezza:{Lunghezza}困难:{Difficolt}

”+ “{prova}”, },

帮助会很棒的!

您需要在
itemtap
功能中进行liitle更改

    '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 ....

         }
     }

尚未尝试此操作,但您可能还需要在两个子
面板
上实际调用
setData()
。在两个子面板中添加
setData()
是什么意思?在
中包含的两个
面板
。调用方法与调用
setData()相同
detailsView
上,但在那些子级上,而不是在
detailsView
本身上(或者可能是在其他子级上,取决于您将其更改为什么)谢谢你,伙计,你让我开心了,新的
itemtap
功能开始工作了!现在我在我的第一个项目面板中提取我的门店数据。顺便说一下,我不明白什么是
detailsView.getAt(1)
do。我是sencha编程和javascript编程的新手。这个函数允许我从我的
项目中访问我的存储数据
?索引的数字是什么意思?谢谢!
getAt()
方法从容器的
items
数组返回组件。
items
是一个组件数组,因此
getAt(0)
将返回
items
数组和getAt(1)中的第一个元素will reutrn second element.这样我甚至可以直接从我的
itemtap
功能设置我的详细信息视图
title