setValue()没有在combox字段-EXTJS中存储正确的值

问题描述 投票:0回答:1

我想动态设置一个值,

 $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”

如何解决这个问题?谢谢!

javascript extjs
1个回答
0
投票

数据定义应该是这样使用键,如在定义的字段中'

fields: ['key', 'title'],
    data : [
            {"key":"titletest", "title":"Title"},
            {"key":"nametest", "title":"Name"}
    ]
© www.soinside.com 2019 - 2024. All rights reserved.