2016-08-20 33 views
0

是否有人知道如何獲得id_produs值?如何從xtemplate獲得父值

這是代碼

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值,因爲我不沒有有效的身份證號碼 有人可以給我一個提示嗎?

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

回答

0

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; 
    } 
}); 
0
listeners: { 
      scope: this, 
      itemclick: function (record, item, index, e, eOpts) { 
       console.log(item.data.id_produs);     
      } 
     } 
+0

雖然這個代碼片斷可以解決這個問題,它沒有解釋爲什麼不然怎麼回答了這個問題。請[請提供您的代碼解釋](// meta.stackexchange.com/q/114762/269535),因爲這確實有助於提高帖子的質量。請記住,您將來會爲讀者回答問題,而這些人可能不知道您的代碼建議的原因。 **舉報人/評論者:** [僅限代碼解答,例如downvote,請勿刪除!](// meta.stackoverflow.com/a/260413/2747593) –