2017-01-29 75 views
-1

我有一个多选组合框,它是另一个组合框的targetcombo。ExtJs组合框没有设置值

以下是数据库的一些值。

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。 请帮忙。

+1

我为你创建了一个小提琴https://fiddle.sencha.com/#view/editor&fiddle/1p50,setValue(103)适合我。但我不明白你的意思是什么价值分割。你可以有多个值?它不适合我。你能用小提琴重新创造你的确切问题吗? – pagep

回答

0

更好使用Ext.form.field.Tag。因为Combo multiselect从版本5.1.0开始已弃用。

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' 
     } 
    ] 

});