2012-01-26 16 views
2

我正在使用Extjs 4.0.7,並且在combobox上的選定選項的formPanelsubmitfieldValue中難以獲得combobox如何在Extjs 4中提交組合框的fieldValue?

至於我可以告訴大家,這是通常是通過設置hiddenName配置選項,你想讓它作爲提交值的值實現;就像在HTML中使用一個隱藏字段,但hiddenName選項現在似乎從文檔刪除,沒有任何明顯的替代品。

那麼如何繼續關於在Extjs 4中提交valueField的值formPanel

這是我的應用程序,在那裏我定義組合框之一,可謂物美價廉:

xtype: 'combobox', 
     name: 'shift', 
     hiddenName: 'shiftid', 
     id: 'shiftCombobox', 
     fieldLabel: 'Shift', 
     labelWidth: 30, 
     width: 130, 
     margin: '0 5', 
     cls: 'shift', 
     store: shiftStore, 
     autoSelect: true, 
     queryMode: 'local', 
     displayField: 'name', 
     valueField: 'objectid', 
     autoSelect: true, 
     handler: function() { 
      //changeShift(); 
     } 

,這是該shiftStore使用模型:我已經忘了這碼

Ext.define('shiftModel', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     {name: 'objectid', type: 'int'}, 
     {name: 'name', type: 'string'} 
    ] 
}); 
+0

我找到了解決辦法,但不能回答我的問題呢。隨意張貼了堅實的方式來控制被提交雖然 – Wertisdk 2012-01-27 00:05:49

+0

http://stackoverflow.com/a/5724225/6294有解決方案。 – Maggie 2012-01-28 20:56:49

回答

0

autoLoad: { 
     //The callback here is needed to fix a bug and set a default value in the combobox. 
     scope: this, 
     callback: function() { 
      var comboBox = Ext.getCmp("teamCombobox"); 
      var store = comboBox.store; 

      // set the value of the comboBox here 
      comboBox.setValue(store.getAt('0').get('name')); 
     } 
    } 

哪個更新comboboxcombobox的商店autoLoad,在加載時使用默認值。 我的值設置爲這是displayValue。將值設置爲相應的fieldValue,在我的情況下,現場叫OBJECTID

後,我將它設置這樣的,它的工作原理:

comboBox.setValue(store.getAt('0').get('objectid')); 

現在combox提交它是真實的fieldValue而不是文本值我意外地設置了。

我仍想知道是否有某種方式來控制這雖然。