在没有商店的组合框中添加一个值
Add a value in combobox without a store
我正在使用 REST 服务与服务器通信,该功能 returns 一个 HashMap。我需要使用此 HashMap 来填充组合框。我已发出 ajax 检索该 HashMap 的请求(在 javascript var 中)。现在我有了这个 HashMap,我需要在组合框中添加 'keys' 作为选项。
是否可以借助某些插入函数而不创建存储,因为我的 HashMap 本身就像一个存储。我该如何实现?
我想做这样的事情:
for (var field in json) {
combo.add(field) // Is there any function or a way by which I can do this
}
也许将其转换为 Ext.data.Records 的数组并添加使用如下所示的东西
Ext.getCmp('COMBO_ID').getStore().add([new Ext.data.Record({
id: 900,
desc: 'qweqwe' // depends on your combo config
}
)]);
// complete
var combo = Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
id: 'mycombo',
queryMode: 'local',
displayField: 'name',
valueField: 'id',
store: [],
renderTo: Ext.getBody()
});
combo.getStore().add([[2, 'qweqwe']]);
我正在使用 REST 服务与服务器通信,该功能 returns 一个 HashMap。我需要使用此 HashMap 来填充组合框。我已发出 ajax 检索该 HashMap 的请求(在 javascript var 中)。现在我有了这个 HashMap,我需要在组合框中添加 'keys' 作为选项。
是否可以借助某些插入函数而不创建存储,因为我的 HashMap 本身就像一个存储。我该如何实现?
我想做这样的事情:
for (var field in json) {
combo.add(field) // Is there any function or a way by which I can do this
}
也许将其转换为 Ext.data.Records 的数组并添加使用如下所示的东西
Ext.getCmp('COMBO_ID').getStore().add([new Ext.data.Record({
id: 900,
desc: 'qweqwe' // depends on your combo config
}
)]);
// complete
var combo = Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
id: 'mycombo',
queryMode: 'local',
displayField: 'name',
valueField: 'id',
store: [],
renderTo: Ext.getBody()
});
combo.getStore().add([[2, 'qweqwe']]);