Sencha Touch:将数据从onItemDisclosure传递到详细视图面板和模板

时间:2011-09-27 11:08:15

标签: sencha-touch

我将通常的数据传递到我的 onItemDisclosure ,如下所示:

  onItemDisclosure: function(record, btn, index) {
       console.log(record.data);
  }...

我可以看到数据没有问题,但我想将这些数据传递到我的面板上,以便其模板可以使用它吗?

我该怎么做呢。

到目前为止,我在详细的面板中有这个,但在面板代码中我该如何抓住它?

detailPanel.update(record.data);

更新

好好玩一下它似乎我正常地将数据变量放在模板中并且整个过程都有效

    <tpl for="."><div>{name}</div></tpl>

但是我的另一个问题是我的json设置了如下字段:

  "name"," joe bloggs",
   "contacts": [
            {
                "home":"0844 482 5171",
                "mobile":"",
                "work":"0844 482 5100"          
            }],.....

现在我可以访问这些console.log(contacts[0].mobile),但如果我将其放在模板<tpl for="."><div>{contacts[0].mobile}</div></tpl>中,则只需打印出{contacts[0].mobile}

那么如何在联系人中获取这些数据?

1 个答案:

答案 0 :(得分:1)

<强>更新

使用<tpl for="contacts">{mobile}</tpl>

<强>端

tpl属性添加到detailPanel对象,如下所示:

tpl:'<h1>{text}</h1>'

其中textrecord.data对象的某些属性。

以下是有关sencha模板的一些很好的教程:

http://www.sencha.com/learn/xtemplates-part-i/

http://www.sencha.com/learn/xtemplates-part-ii/

相关问题