Extjs4 如何从extjs 4中接收的存储数据设置combobox id

Extjs4 如何从extjs 4中接收的存储数据设置combobox id,extjs4,extjs-mvc,Extjs4,Extjs Mvc,我的formpanel中有一个组合框。最初,我使用该表单将有关公司的新信息添加到数据库中 现在我有了一个包含公司信息的网格,当我根据Id点击它时,它将返回公司商店的完整信息 有了这些所有数据我还获得了组合框国家、州、城市的id,我无法根据收到的国家id、州id、城市id设置组合框的值 我的json公司数据如下所述 { "companydata": [{ "city": { "cityname": "Patna", "

我的formpanel中有一个组合框。最初,我使用该表单将有关公司的新信息添加到数据库中

现在我有了一个包含公司信息的网格,当我根据Id点击它时,它将返回公司商店的完整信息

有了这些所有数据我还获得了组合框国家、州、城市的id,我无法根据收到的国家id、州id、城市id设置组合框的值

我的json公司数据如下所述

    {
    "companydata": [{
        "city": {
            "cityname": "Patna",
            "stateid": 2,
            "cityid": 2,
            "cityzipcode": null
        },
        "cmpname": "Kintu Designs Pvt ltd",
        "cmptitle": "Kintu Designs Pvt ltd",
        "cmpcontact": "8128812153",
        "cmpdesc": "<b>?Kintu designs Surat</b>",
        "cmpfax": "8128812153",
        "cmpwebsite": "www.kintudesigns.com",
        "cmpemail1": "yaryan997@gmail.com",
        "cmpemail2": "yaryan997@gmail.com",
        "cmplogo": "calendar.png",
        "cmplogopath": "upload/images/",
        "cmpaddress": "Kintu designs Surat",
        "cmpcreatedby": 1,
        "cmpcreatedon": 1199932743000,
        "cmpmodifiedon": 1199932743000,
        "cmpmodifiedby": 0,
        "id": 1,
        "state": {
            "statename": "Bihar",
            "countryid": 1,
            "stateid": 2
        },
        "country": {
            "countryid": 1,
            "countryname": "India"
        }
    }],
    "total": 1,
    "success": true
}
editCompany: function(grid, no, rowindex,colindex,temp) {  
        alert('EDIT COMPANY BUTTON PRESSED');
        var rec = this.getCompanyDetail().store.getAt(rowindex);
        console.log(rec);
        var actionid = grid.getCellByPosition( {row:rowindex,column:colindex } ).id;    
        this.getCompanyEdit().animateTarget=actionid;
        this.getCompanyEdit().editform=1;
        //this.getCompanyEditForm().getForm().reset();
        this.getCompanyEditForm().loadRecord(rec);                  
        this.getCompanyEdit().show();
    },
单击网格时执行的我的控制器功能

    {
    "companydata": [{
        "city": {
            "cityname": "Patna",
            "stateid": 2,
            "cityid": 2,
            "cityzipcode": null
        },
        "cmpname": "Kintu Designs Pvt ltd",
        "cmptitle": "Kintu Designs Pvt ltd",
        "cmpcontact": "8128812153",
        "cmpdesc": "<b>?Kintu designs Surat</b>",
        "cmpfax": "8128812153",
        "cmpwebsite": "www.kintudesigns.com",
        "cmpemail1": "yaryan997@gmail.com",
        "cmpemail2": "yaryan997@gmail.com",
        "cmplogo": "calendar.png",
        "cmplogopath": "upload/images/",
        "cmpaddress": "Kintu designs Surat",
        "cmpcreatedby": 1,
        "cmpcreatedon": 1199932743000,
        "cmpmodifiedon": 1199932743000,
        "cmpmodifiedby": 0,
        "id": 1,
        "state": {
            "statename": "Bihar",
            "countryid": 1,
            "stateid": 2
        },
        "country": {
            "countryid": 1,
            "countryname": "India"
        }
    }],
    "total": 1,
    "success": true
}
editCompany: function(grid, no, rowindex,colindex,temp) {  
        alert('EDIT COMPANY BUTTON PRESSED');
        var rec = this.getCompanyDetail().store.getAt(rowindex);
        console.log(rec);
        var actionid = grid.getCellByPosition( {row:rowindex,column:colindex } ).id;    
        this.getCompanyEdit().animateTarget=actionid;
        this.getCompanyEdit().editform=1;
        //this.getCompanyEditForm().getForm().reset();
        this.getCompanyEditForm().loadRecord(rec);                  
        this.getCompanyEdit().show();
    },
我的公司商店是

Ext.define('rms.store.company', {
extend: 'Ext.data.Store',
model: 'rms.model.companyModel',
storeId: 'companyStore',
autoLoad: true,
 proxy: {
    type: 'ajax',
    api: {
        read : 'company/GetCompany.action',
        create : 'company/CreateCompany.action',
        update: 'company/UpdateCompany.action',
        destroy: 'company/DeleteCompany.action'
    },
    reader: {
        type: 'json',
        root: 'companydata',
        totalProperty: 'total',
        successProperty: 'success'

    },
    writer: {
        type: 'json',
        writeAllFields: true,
        encode: true,
        root: 'companydata'
    }
}
}))

而我的公司模式是

Ext.define('rms.model.companyModel', {
extend: 'Ext.data.Model',
fields : [
          { name: 'id', type: 'int', useNull: true, mapping: 'id'},
          { name: 'cmpname', type: 'string', mapping: 'cmpname'},
          { name: 'cmptitle', type: 'string', mapping: 'cmptitle'},
          { name: 'cmpdesc', type: 'string', mapping: 'cmpdesc'},
          { name: 'cmpfax', type: 'string', mapping: 'cmpfax'},
          { name: 'cmpcontact', type: 'string', mapping: 'cmpcontact'},
          { name: 'cmpwebsite', type: 'string', mapping: 'cmpwebsite'},
          { name: 'cmpemail1', type: 'string', mapping: 'cmpemail1'},
          { name: 'cmpemail2', type: 'string', mapping: 'cmpemail2'},
          { name: 'countryname', type: 'int', mapping: 'country'},
          { name: 'statename', type: 'int', mapping: 'state'},
          { name: 'cityname', type: 'int', mapping: 'city'},
          { name: 'cmplogo', type: 'string', mapping: 'cmplogo'},
          { name: 'cmplogopath', type: 'string', mapping: 'cmplogopath'},
          { name: 'cmpaddress', type: 'string', mapping: 'cmpaddress'},
      ]
}))

从服务器响应中,我收到countryid、stateid、cityid。但我无法使用收到的id设置组合框。
请帮我解决这个问题。

您的门店“国家”在哪里?它是如何定义的?

您希望您的组合框中加载所有门店型号和您要传递的选定型号的列表,还是只包含您要传递的型号


另外,尝试在每个组合框项目中设置属性
queryMode:local
,以防…

我更新了我的问题。请给我建议一些解决方案,我可以试着解决我的问题。你在哪里为组合框加载商店?请记住,加载过程是异步的,当您将其他存储值加载到formI had update my question并添加companyStore和companyModel时,加载过程仍然可以加载。请查看它,并帮助我在编辑窗口中设置country、state、city的组合框。您的country/state/city商店很可能未加载。我有四个商店和公司,country、state、city。我的公司商店会返回要在国家组合框上设置的正确数据,但仍然无法正确设置组合框。我有四个商店:国家组合的countryStore、国家组合的stateStore、城市组合的cityStore和公司组合的companyStore。当我单击公司网格列表时,它会打开EditCompany窗口。如上所述,我正在从服务器响应获取json数据,但仍然无法在编辑窗口中设置国家、州和城市的组合框。请给我建议一些解决方案,我被卡住了。您是否尝试将每个组合设置为
queryMode:local
?是否尝试将每个组合设置为
queryMode:local
?我还建议您在每个组合框定义中使用(
store:Ext.StoreManager.Lookup('company'))
而不是
存储:'company'
很抱歉,我仍然不明白您是否无法填充组合框,或者是否填充了组合框但无法选择相应的项目。