1

Given the following javascript:

var fo = Ext.create('Ext.form.Panel', {
    layout:'box',
    ...
    items: [{
        xtype: 'combobox',
        valueField: 'id',
        displayField: 'organizationtype',
        store: {
            storeId: 'zaza',                
            fields: [{name: 'id'}, {name: 'organizationtype'}],
            root: 'data',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url: '/apps/crm_organizations/orgtype/',
                reader: {
                    type: 'json'
                }
            }
        },
        fieldLabel: 'Type relation',
        name: 'organizationtype',
        queryMode: 'local',
    },
            ...

This panel contains - among other fields - also this combobox. I can see with wireshark that the url '/apps/crm_organizations/orgtype/' is actually queried. However the combobox doesn't show any values. Has this anything to do with the fact that I'm lazy loading the combobox?

This is the response on the JSON request:

{data: [ {id:"1" ,organizationtype:"Customer"} 
,{id:"2" ,organizationtype:"Relation"} 
,{id:"3" ,organizationtype:"Supplier"} 
,{id:"4" ,organizationtype:"Unknown"} ]}
4

3 回答 3

0

您必须将根设置为您正在使用的 json 阅读器,默认为“”,您的应该是:

reader: {
                    type: 'json',
                    root: 'data'
                }

您也可以考虑用模型对象替换字段配置。(来自文档)字段:通常应避免使用此配置选项,它的存在是为了向后兼容

于 2012-07-24T11:55:58.357 回答
0

将组合框模式从本地更改为远程mode: 'remote'并使用 json 存储:

store: {
    xtype: 'jsonstore',
    url: '/apps/crm_organizations/orgtype/',
    autoLoad: true,
    idProperty: 'id',
    root: 'data',
    fields: ['id','organizationtype'],
},
mode: 'remote'
于 2012-07-24T12:13:19.397 回答
0

在您的商店中,您缺少根属性

store: {
  storeId: 'zaza',       
  fields: [{name: 'id'}, {name: 'organizationtype'}],
  root: 'data',
  autoLoad: true,
  proxy: {
    type: 'ajax',
    url: '/apps/crm_organizations/orgtype/',
    reader: {
      type: 'json',
      root:'data'
    }
  }
}

如果您的组合是跨域查询信息,则使用 jsonp 配置并使用远程查询以获得更好的性能

于 2012-07-24T12:32:35.360 回答