2012-01-26 53 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而不是文本值我意外地设置了。

我仍想知道是否有某种方式来控制这虽然。