gpt4 book ai didi

javascript - 组合框显示为空 - Ext.JS 4

转载 作者:行者123 更新时间:2023-11-28 18:28:56 24 4
gpt4 key购买 nike

我正在尝试在组合框中显示值,如下所示:

Ext.define('Pgmtems.view.combo.DepoTurCombo', {
extend : 'Ext.form.field.ComboBox',
alias : 'widget.depoturcombo',
fieldLabel : 'Depo Cinsi',
displayField : 'aciklama',
valueField : 'value',
typeAhead : true,
forceSelection : true,
enableKeyEvents : true,
emptyText : '-Depo Cinsi-',
editable : false,
labelWidth : 70,

constructor : function(cfg) {
console.warn(cfg.xtype, " constructor arld.");
var me = this;
Ext.apply(this, cfg);
var store = Ext.create('Ext.data.Store', {
autoLoad : true,
fields : ['value', 'aciklama'],
data : [[3, "TL"], [2, "YTL"], [1, "ETL"]]
});
Ext.apply(this, {
store : store
});
this.callParent(arguments);
},
initComponent : function() {
console.log('DepoTurCombo initComponent');
this.trigger1Cls = 'x-form-clear-trigger';
this.trigger2Cls = 'x-form-arrow-trigger';
this.callParent(arguments);
},
onTrigger1Click : function() {
this.clearValue();
}
});

但是,它不显示组合框值。正如您所看到的,Depo Cinsi 值是空的(实际上我可以看到 3 个项目,但它们的名称没有出现)。

关于如何解决这个问题有什么想法吗?

enter image description here

最佳答案

使用Ext.data.ArrayStore而不是Ext.data.Store:

Small helper class to make creating Ext.data.Stores from Array data easier. An ArrayStore will be automatically configured with a Ext.data.reader.Array.

工作示例:https://fiddle.sencha.com/#fiddle/1e2p

<小时/>

如果您想使用Ext.data.Store而不使用Ext.data.reader.Array,您需要像这样传递数据:

data: [{value: 3, aciklama: "TL"}, {value: 2, aciklama: "YTL"}, {value: 1, aciklama: "ETL"}]

关于javascript - 组合框显示为空 - Ext.JS 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38521212/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com