2012-10-10 95 views
0

首先代碼的一小部分:煎茶網格:隱藏的列和組合框

{    text: 'TipoVisitaID', 
      hidden: true, 
      dataIndex: 'TipoVisitaID', 
      itemId: 'TipoVisitaID' 
     }, { 
      text: 'TIPO VISITA', 
      flex: 1, 
      sortable: true, 
      align: 'right', 
      dataIndex: 'TipoVisita', 
      editor: { 
       xtype: 'combo', 
       allowBlank: true, 
       store: allTiposVisita, 
       valueField: 'Id', 
       name: 'TiposVisitaCombo', 
       itemId: 'TiposVisitaCombo', 
       tpl: Ext.create('Ext.XTemplate', 
            '<tpl for=".">', 
             '<div class="x-boundlist-item">{Designacao}</div>', 
            '</tpl>'), 
       displayTpl: Ext.create('Ext.XTemplate', '<tpl for=".">', '{Designacao}', '</tpl>') 
      } 
     }, 

什麼我想achivie是這樣的。

編輯行時,我希望組合的選定值爲隱藏字段中的值。

這甚至可能嗎?

我試着這樣做:(在組合)

value: Ext.ComponentQuery.query("#TipoVisitaID")[0] == null ? '' : Ext.ComponentQuery.query("#TipoVisitaID")[0].value 

,但它不工作...

+0

你想什麼時候這樣做?使用getValue()方法而不是'value'。 – A1rPun

+0

getValue()也不起作用...我想在內聯編輯開始時,組合框具有預選值。 –

回答

0

我已經解決了這個問題。

{ 
      text: 'TIPO VISITA', 
      flex: 1, 
      sortable: true, 
      align: 'right', 
      dataIndex: 'TipoVisitaID', 
      renderer: function (loader, response, active) { 
       return active.raw.TipoVisita; 
      }, 
      editor: { 
       xtype: 'combo', 
       allowBlank: true, 
       store: allTiposVisita, 
       valueField: 'Id', 
       name: 'TiposVisitaCombo', 
       itemId: 'TiposVisitaCombo', 
       tpl: Ext.create('Ext.XTemplate', 
            '<tpl for=".">', 
             '<div class="x-boundlist-item">{Designacao}</div>', 
            '</tpl>'), 
       displayTpl: Ext.create('Ext.XTemplate', '<tpl for=".">', '{Designacao}', '</tpl>') 
      } 
     }, 

首先我將dataIndex更改爲ID。但現在用戶會看到ID而不是數據,這就是爲什麼我使用渲染器以便用戶看到數據而不是ID。與該ID

Ext.ComponentQuery.query("#TiposVisitaCombo")[0].setValue(e.record.raw.TipoVisitaID); 

因此設置在組合的值(使它預選一個):

我然後添加偵聽「beforeedit」,其中我這樣做的網格。

0

添加事件監聽器來編輯在網格和更新數據事件你從那裏隱藏的領域。編輯完成後,此事件將觸發。

grid.on('edit', function (editor, e){ 
    e.record.set('TipoVisitaID', e.value); 
} 
+0

這隻在用戶直接點擊單元格時才起作用...我希望預選值獨立於單擊單元格「出現」... –

0

你在找這樣的嗎?

var theHidden = Ext.getCmp('TipoVisitaID'); 
var theCombo = Ext.getCmp('TiposVisitaCombo'); = 
theCombo.on('change', function(combo, newValue, oldValue, e){ 
    theHidden.setValue(newValue); 
}); 
+0

Ext.getCmp('#TipoVisitaID')返回未定義。另外我想要的是像Combo.setValue(theHidden),所以當組合呈現隱藏的值將是預先選定的。 –

+0

糟糕我的錯誤,我幾乎不使用getCmp,我沒有測試代碼。你可以使用你的代碼我猜 – A1rPun

+0

謝謝你的幫助:)它的作品如此:) –