Combobox extjs4组合框中继值
我在表单中有一个comboBox,valueField是mongodb中文档的ObjectId字段,它在comboBox中显示字段的正确值,但它只返回一部分值和getValue,getRawValue返回displayField的值。 这是组合框的代码:Combobox extjs4组合框中继值,combobox,extjs4.1,Combobox,Extjs4.1,我在表单中有一个comboBox,valueField是mongodb中文档的ObjectId字段,它在comboBox中显示字段的正确值,但它只返回一部分值和getValue,getRawValue返回displayField的值。 这是组合框的代码: { xtype: 'combo', fieldLabel:'Firm', store:Ext.data.StoreManager.lookup('bbCompaniesStore'),
{
xtype: 'combo',
fieldLabel:'Firm',
store:Ext.data.StoreManager.lookup('bbCompaniesStore'),
displayField: 'firm',
valueField: '_id',
name: 'country',
labelAlign: 'top',
cls: 'field-margin',
flex: 1
}
这是我从表格中获取值的方式:
var nomeField = formPanel.items.get(0).items.get(0);
var firmField = formPanel.items.get(0).items.get(1);
var noteField = formPanel.items.get(0).items.get(2);
var contact = Ext.ModelManager.create({nome: nomeField.getValue(), note: noteField.getValue(),'firm_id':firmField.getValue()}, 'Contact');
它可以工作,但它对_id的值进行集群,我使用firebug进行了检查,服务器发送rigth数据,我认为extjs进行了某种规范化,在我使用getRawValue进行解决之前,但是使用combobox它返回displayField。我不知道如何解决此问题。您的id是什么样子的?您的店铺定义(或型号,如果适用)如何?我想问题可能是您使用的id类型(模型上字段的类型)。我的模型是:Ext.define('Company',{extend:'Ext.data.model',字段:[{name:'u id',type:'int'},{name:'firm'},{name:'note'},{name:'paese'}),代理:{type:'rest',url:'data/companys/'}});虽然我的id是由mongodb自动生成的:“513e727e44ae2025845e6efb”您是否尝试将id类型设置为StringThank谢谢,我没有对id做任何处理。嗯,您说您没有对id做任何处理,但这是一个哈希,并且您的模型中的id为int,这就是问题所在,请将其更改为:`{name:''u id',键入:'string'}`,这应该对您有帮助。