extjs - 使用 JSON 值填充组合框
问题描述
我需要用 JSON 数据填充组合框。这是我的商店:
Ext.define('Test.store.GetShopSurvey', {
extend: 'Ext.data.Store',
alias: 'store.GetShopSurvey',
model: 'Test.model.GetShopSurvey',
storeId: 'GetShopSurvey',
proxy: {
type: 'ajax',
url: 'http://localhost/webcontent/CShopSurveyWebApplet&SubFunc=GetShopSurvey',
reader: {
type: 'json',
}
}
});
而我的观点:
Ext.define('Test.view.main.Announcement',
{
extend: 'Ext.panel.Panel',
requires: [
'Test.view.main.AnnouncementController',
'Test.view.main.AnnouncementModel',
'Test.store.Personnel'
],
store: {
type: 'GetShopSurvey'
},
其中一项是:
{
xtype: 'combo',
fieldLabel: 'Range',
name: 'Range1',
store: , //here I need store to load. For example json value is {"range": 70}
displayField: 'range',
autoSelect: true,
forceSelection: true,
disabled: true
},
我使用名称和数据类型将字段添加到模型中。但是,我不知道如何从 JSON 中获取数据并在组合框中解析它。我评论了我需要放置该值的地方。
解决方案
试试 loadRawData 方法
var jsonData = {'range':500};
combo.getStore().loadRawData(jsonData);
推荐阅读
- java - Collections.emptyList() 与 Collections::emptyList 有什么区别
- javascript - 如何合并两个文件 API (Node.js)
- rest - 如何通过邮递员使用基本身份验证发送多部分/表单数据请求?
- apache-spark - Spark 加入性能问题
- c++ - 模棱两可的函数调用:将模板参数传递给许多覆盖函数之一
- r - 将 for 循环中的多个数据帧保存为单独的 CSV
- python - 如何在类中包含函数属性?
- postgresql - Sequelize:如何对包含的第 3 级模型进行 COUNT
- jquery - 在使用 Django i18n 模式时,在将 POST 方法的 AJAX 调用转换为 GET 方法期间
- python-3.x - 如何在熊猫数据框中将“一个热编码”列名从字节解码为字符串