【问题标题】:ExtJs combobox not setting valueExtJs组合框未设置值
【发布时间】:2017-01-29 11:37:57
【问题描述】:

我有一个多选组合框,它是另一个组合框的目标组合。

以下是数据库中的一些值。

101 - 粉红色
102 - 红色
103 - 深蓝色

我正在使用 setValue 设置组合框的值。但我发现它只有在值不包含空格时才有效。 例如-

combobox1.setValue(101);   // Works
combobox1.setValue(102);   // Works
combobox1.setValue(103);   // Does Not Work

还有,

var val = '101,102';
combobox1.setValue(val.split(',')); // Works well. Displays 'Pink, Red'

但是

var val = '101,103';
combobox1.setValue(val.split(',')); // Displays only 'Pink'

我在这里做错了吗?或错过任何东西。问题是否与targetcombo有关。 请帮忙。

【问题讨论】:

  • 我为你创建了小提琴fiddle.sencha.com/#view/editor&fiddle/1p50,setValue(103) 对我有用。但我不明白你所说的价值分裂是什么意思。你可以有多个值吗?它对我不起作用。你能用小提琴重现你的确切问题吗?

标签: extjs combobox extjs6


【解决方案1】:

最好使用 Ext.form.field.Tag。因为从 5.1.0 版本开始不推荐使用 Combo 多选。

Ext.define('Ext.form.field.Tag', {
    items: [
        {
            xtype: 'tagfield',
            id: 'tagF',
            valueField: 'value',
            store: 'CustomStore',
        },
        {
            xtype: 'button',
            handler: function(button, e) {
                Ext.first('#tagF').setValue(101)
            },
            text: '101'
        },
        {
            xtype: 'button',
            handler: function(button, e) {
                Ext.first('#tagF').setValue(102)
            },
            text: '102'
        },
        {
            xtype: 'button',
            handler: function(button, e) {
                Ext.first('#tagF').setValue(103)
            },
            text: '103'
        },
        {
            xtype: 'button',
            handler: function(button, e) {
                var val = '101,102';
                Ext.first('#tagF').setValue(val.split(','));
            },
            text: 'split'
        }
    ]

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多