【问题标题】:How to get the parent value from xtemplate如何从 xtemplate 获取父值
【发布时间】:2016-08-20 16:41:03
【问题描述】:

有谁知道我如何获得 id_produs 值?

这是代码

 var tplv_cos = new Ext.XTemplate(
        '<tpl for=".">',
            '<div class="thumb_cos" id="{id_produs}">',
            '<div align="right" class="tpl-add-button"></div>',
            '<br>',
              '<img src = "imagini/{imagine}" id="ttt">',
              '<br>',
              '<b>{denumire}</b>',
              '<br>',
              '<b>Pret : {pret}</b>',
              '<div id="id_dv_txtf" style="width: 16%" class="comment-add-textfield"></div>',
             '</div>',
        '</tpl>',
    {
        compiled:true
    }); 

    var view_cos = Ext.create('Ext.DataView', { 
         id:    'idv_cos',
         itemSelector:'div.tpl-add-button',
         renderTo: Ext.getBody(),
         store: store_view_cos,
         tpl: tplv_cos,
         listeners: {
             refresh:function(){
                var renderSelector = Ext.query('div.comment-add-textfield'); 
                    for(var i in renderSelector){
                        Ext.create('Ext.form.field.Text',{
                            value: 1,
                            renderTo:renderSelector[i],
                              listeners: {
                                    change: function(c, node){
                                        alert(Ext.query('div.thumb_cos')[0])
                                    //this.getValue(c)

这里我需要当前文本字段的 id_produs 值

在这里我得到了更改的值,但我无法将数据发送到服务器,因为我没有有效的 id 有人可以给我一个提示吗?

                        }
                            }
                });   
            }
            var renderSelector1 = Ext.query('div.tpl-add-button'); 
            for(var j in renderSelector1){
                Ext.create('Ext.Button',{
                    text: 'X',
                    renderTo:renderSelector1[j]
                });   
            } 
    }

【问题讨论】:

    标签: extjs extjs4.2


    【解决方案1】:

    XTemplate API

    我认为这很有用;

    var tpl = new Ext.XTemplate(
    '<p>Name: {name}</p>',
    '<p>Kids: ',
    '<tpl for="kids">',
        '<tpl if="this.isGirl(name)">',
            '<p>Girl: {name} - {age}</p>',
        '<tpl else>',
            '<p>Boy: {name} - {age}</p>',
        '</tpl>',
        '<tpl if="this.isBaby(age)">',
            '<p>{name} is a baby!</p>',
        '</tpl>',
    '</tpl></p>',
    {
        // XTemplate configuration:
        disableFormats: true,
        // member functions:
        isGirl: function(name){
           return name == 'Aubrey' || name == 'Nikol';
        },
        isBaby: function(age){
           return age < 1;
        }
    });
    

    【讨论】:

      【解决方案2】:
       listeners: {
                  scope: this,
                  itemclick: function (record, item, index, e, eOpts) {
                      console.log(item.data.id_produs);                   
                  }
              }
      

      【讨论】:

      猜你喜欢
      • 2016-08-17
      • 2013-07-25
      • 2014-11-05
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多