我有一个多选组合。当用户从组合中选择一个值时,将显示该值。现在我想在用户选择的值中添加一个字符串,它应该以组合形式显示而不是用户的选定值
答案 0 :(得分:1)
好像你正在寻找你的组合框的displayTpl配置(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]}'
)
}
}
});