javascript - setValue() 没有在组合框字段-EXTJS 中存储正确的值
问题描述
我想动态设置一个值,
$cls.superclass.constructor.call(this, Ext.apply({
autoHeight: true,
items: [
this.combo = new Ext.form.ComboBox({
width: 75,
emptyText: $L('Select...'),
mode: 'local',
displayField : 'title',
valueField: 'key',
triggerAction: 'all',
store: new Ext.data.ArrayStore({
fields: ['key', 'title'],
data: [
["titletest","Title"],
["nametest","Name"]]
}),
listeners: {
'select': function(){
this.show();
},
scope: this
}
})]
},cfg));
我愿意:
show: function(fld) {
this.combo.setValue(fld.value);
}
fld.value 将值设置为“nametest”或“titletest”而不是“Title”或“Name”
如何解决这个问题?谢谢!
解决方案
数据定义应该像这样使用定义的字段中的键'
fields: ['key', 'title'],
data : [
{"key":"titletest", "title":"Title"},
{"key":"nametest", "title":"Name"}
]
推荐阅读
- python - 如何使用索引访问列表中的联合字符串的信息
- python - 如何绕过python认证错误?
- mariadb - 带有 Heidisql JSON_REMOVE 的 MariaDB 无法正常工作
- c# - 如何根据控件的名称查找控件的位置
- visual-studio - ConsoleApp1 依赖于 System.Configuration.ConfigurationManager (>= 4.0.3)
- sinatra - Uglifier 和谐模式 ES6
- java - 如何使用 Java 集成测试调用 Drools 规则
- python - 格式化和比较数组 Numpy Python
- python - 基于 groupby 过滤器的 Pandas 数据帧拆分
- tcl - 无法在 tcl 中增加环境变量