【问题标题】:Extjs Rendering value using idExtjs 使用 id 渲染值
【发布时间】:2017-07-31 14:38:38
【问题描述】:

我正在尝试通过 id 获取值

 window.setInterval(function () {
                me.updateData({
                    Name: "aaa, aaa",
                    Id: "1234",
                    Vitals: [{
                        Name: "value1",
                        Timestamp: new Date(),
                        Value: getRandomInt(60, 80) + "/" + getRandomInt(60, 80)
                    }, {
                        Name: "value2",
                        Timestamp: new Date(),
                        Value: getRandomInt(60, 80)
                    }, {
                        Name: "value3",
                        Timestamp: new Date(),
                        Value: getRandomInt(60, 80)
                    }, {
                        Name: "value4",
                        Timestamp: new Date(),
                        Value: getRandomInt(60, 80)
                    }
                    ]
                });              
            }, 1000);

items: [{
            id:'value'
                   ,tpl: 
                        '<div class="col-md-3 red ">{Value}</div>' 
                }

以上场景运行良好。 但我需要通过像

这样动态生成的 div 来使用它
items: [{
                   tpl: 
                        '<div id="value" class="col-md-3 red ">{Value}</div>'                 
                }

但是 {Value} 中的值没有绑定 谢谢你

【问题讨论】:

  • 您能否发布整个代码以便更好地了解您要执行的操作?也许在小提琴中。

标签: javascript extjs dynamic reference frameworks


【解决方案1】:

请尝试以下代码。

items: [{
        xtype: 'dataview',
        itemId: 'ItemId',
        tpl: new Ext.XTemplate(
            '<tpl for=".">',
                '<div class="col-md-3 red ">',
                    '<h3>{value}</h3>',
                '</div>',
            '</tpl>'
        ),
        itemSelector: 'col-md-3 red',
        prepareData: function(data, index, record) {
             var name = this.up().getViewModel().get('value');
             var passed = record.get('value') == name;
             return Ext.apply(data);
        }           
     }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多