【问题标题】:EXTJS4 XML Store - XTemplateEXTJS4 XML 存储 - XTemplate
【发布时间】:2012-06-05 13:23:04
【问题描述】:

我有以下模板:

myStore.on('load', function(store, records, options) {
        console.log(records);
        alert("loaded.");
        var tpl = new Ext.XTemplate(
            '<tpl for=".">',
            '<h1>{name} test</h1>',
            '<h1>{origin}</h1>',
            '</tpl>'
        );

        tpl.append(Ext.get("output-body"), myStore);

 });

它遍历我的商店,它有 3 条记录:

accounts { id="accounts-ext-record-1", internalId="ext-record-1"}   
name = "Network"    origin = "Support_4"    id = undefined
accounts { id="accounts-ext-record-2", internalId="ext-record-2"}   
name = "new"    origin = "nevil-nmshub" id = undefined
accounts { id="accounts-ext-record-3", internalId="ext-record-3"}   
name = "soap"   origin = "network"  id = undefined

当我运行代码时,我得到:

test
test
test

输出“name”和“origin”的值我缺少什么?某些东西正在发挥作用,因为它很明显地看到了 3 个帐户,因此出现了 3 个“测试”打印件。谢谢

【问题讨论】:

    标签: extjs extjs4


    【解决方案1】:

    我需要添加数据。在我的tpl中。

    var tpl = new Ext.XTemplate(
                '<tpl for=".">',
                '<h1>{data.name} test</h1>',
                '<h1>{data.origin}</h1>',
                '</tpl>'
            );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-04
      • 2013-08-17
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 2013-06-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多