Extjs组合框-选择器不会更改

Extjs组合框-选择器不会更改,extjs,Extjs,我有以下代码: var comboStore = new Ext.data.Store({ proxy : new Ext.data.HttpProxy({ url : '../cxf/rest/CustomerService/getGroups' }), reader : new Ext.data.JsonReader({ fields : [ 'id', 'name' ] }), autoLoad : true }); 及 加载页面后,值将成功填充到组合框中。 然而,当我

我有以下代码:

var comboStore = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({
    url : '../cxf/rest/CustomerService/getGroups'
}),
reader : new Ext.data.JsonReader({
    fields : [ 'id', 'name' ]
}), 
autoLoad : true
});

加载页面后,值将成功填充到组合框中。 然而,当我试图从组合中选择一个值时,第一个值总是被选中的。我在这里不是以编程的方式讲的,但即使在浏览器上,也会选择第一个值


谢谢

您尝试过使用JsonStore吗?尝试这样做:

var comboStore = new Ext.data.JsonStore({
       id: 'JsonStore',
       idProperty: 'id',
       autoLoad: true,
       idProperty: 'id',
       root: <root of your JSON>,
       fields: [ 'id', 'name' ],
       proxy: new Ext.data.ScriptTagProxy({
           api: {
               read: '../cxf/rest/CustomerService/getGroups',
           }
       })
   });

然后使用组合框的存储区。JsonStore会自动创建JsonReader,我认为这就是代码中的冲突所在。

您是否尝试过使用JsonStore?尝试这样做:

var comboStore = new Ext.data.JsonStore({
       id: 'JsonStore',
       idProperty: 'id',
       autoLoad: true,
       idProperty: 'id',
       root: <root of your JSON>,
       fields: [ 'id', 'name' ],
       proxy: new Ext.data.ScriptTagProxy({
           api: {
               read: '../cxf/rest/CustomerService/getGroups',
           }
       })
   });

然后使用组合框的存储区。JsonStore会自动创建一个JsonReader,我认为这就是代码中的冲突所在。

对不起:我不知道我怎么会没有注意到这一点,但是Json数据存储中的id应该是groupID,而不是'id'。。我更改了这个,它现在可以工作了。

对不起:我不知道我怎么没有注意到这一点,但是Json数据存储中的id应该是groupID,而不是'id'。。我更改了这个,它现在可以工作了。

抱歉:我不知道我怎么会没有注意到这一点,但是Json数据存储中的id应该是groupID istead of'id'。。我更改了此选项,现在可以使用了。添加您的答案并将其标记为已接受,以便有类似问题的人可以看到您如何解决我想要的问题。。但是回答您自己的问题有一定的时间限制:我不知道我怎么会没有注意到这一点,但是Json数据存储中的id应该是groupID istead of'id'。。我更改了此选项,现在可以使用了。添加您的答案并将其标记为已接受,以便有类似问题的人可以看到您如何解决我想要的问题。。但是回答你自己的问题是有时间限制的