有2个combobox 选中左边的数据后 右边自动显示相对应的数据(数据从数据库中查出来的) 如何做到这样的级联查询(asp.net mvc框架) 望高手指点!!!

解决方案 »

  1.   

    就在第一个combobox的selectindexchange的事件中根据第一个选的主键来获取第二个的数据。
      

  2.   

    这个是省市区三级联动的,参考下{
        layout: "form",
        items: { xtype: "combo", fieldLabel: "所在省", width: 130, store: new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: "" }),
            reader: new Ext.data.JsonReader({ id: "Key", root: "data" }, [{ name: "Key" }, { name: "Value"}]), baseParams: { action: "" }, autoLoad: true
        }),
            mode: "local", valueField: "Key", triggerAction: "all", readOnly: true, displayField: "Value", hiddenName: "ProvinceId", name: "ProvinceId", listeners: {
                select: function(combo, record, index) {
                    form.findField("CityId").clearValue();
                    form.findField("CityId").getStore().load({ params: { args: record.id} });
                }
            }
        }, columnWidth: .5
    },
    {
        layout: "form",
        items: { xtype: "combo", fieldLabel: "所在市", width: 130, store: new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: "" }),
            reader: new Ext.data.JsonReader({ id: "Key", root: "data" }, [{ name: "Key" }, { name: "Value"}]), baseParams: { action: "" }
        }),
            mode: "local", valueField: "Key", triggerAction: "all", readOnly: true, displayField: "Value", hiddenName: "CityId", name: "CityId", listeners: {
                select: function(combo, record, index) {
                   form.findField("CountyId").clearValue();
                   form.findField("CountyId").getStore().load({ params: { args: record.id} });
                }
            }
        }, columnWidth: .5
    },
    {
        layout: "form",
        items: { xtype: "combo", fieldLabel: "所在区", width: 130, store: new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: "" }),
            reader: new Ext.data.JsonReader({ id: "Key", root: "data" }, [{ name: "Key" }, { name: "Value"}]),
            baseParams: { action: "" }
        }),
            mode: "local", valueField: "Key", triggerAction: "all", readOnly: true, displayField: "Value", hiddenName: "CountyId", name: "CountyId"
        }, columnWidth: .5
    }