2016-06-08 12 views
0

Ich habe eine Multiselect-Combo. Wenn ein Benutzer einen Wert aus einer Kombination auswählt, wird der Wert angezeigt. Jetzt möchte ich eine Zeichenfolge in der vom Benutzer choosed Wert hinzufügen, und es sollte in Combo nicht der gewählte Wert des BenutzersFeeling Schwierigkeit in Extjs Combo

+0

Welche Version von ExtJS? –

+0

Ich benutze extjs 5 –

+0

, so dass Sie zwei Combos haben? – alex9311

Antwort

1

angezeigt scheint, wie Sie für die displayTpl Config Ihrer Combobox suchen (http://docs.sencha.com/extjs/5.1/5.1.2-apidocs/#!/api/Ext.form.field.ComboBox-cfg-displayTpl)

// The data store containing the list of states 
var states = Ext.create('Ext.data.Store', { 
    fields: ['abbr', 'name'], 
    data : [ 
     {"abbr":"AL", "name":"Alabama"}, 
     {"abbr":"AK", "name":"Alaska"}, 
     {"abbr":"AZ", "name":"Arizona"} 
    ] 
}); 

// Create the combo box, attached to the states data store 
Ext.create('Ext.form.field.ComboBox', { 
    fieldLabel: 'Choose State', 
    store: states, 
    multiSelect: true, 
    queryMode: 'local', 
    displayField: 'name', 
    valueField: 'abbr', 
    renderTo: Ext.getBody(), 
    listeners: { 
     render: function(combo) { 
      combo.setDisplayTpl(
       '{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}' 
      ) 
     } 
    } 
}); 

Fiddle: https://fiddle.sencha.com/#fiddle/1bqu