combo
にはdisplayTpl
の設定が必要です。このFIDDLEで
あなたはExtJSの6.xのに提供して、私はExtJSの4.xので同じ例を作成しました。それは正常に動作しています。これがあなたを導くか、必要な解決策を達成するのを助けてくれることを願っています。
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
title: 'Multiple Seletion Example in ExtJS 4.x for combo box',
items: [{
xtype: 'combo',
margin: 20,
fieldLabel: 'Character Name',
store: Ext.create('Ext.data.Store', {
fields: ['id', 'name'],
data: [{
id: 0,
name: 'John Snow'
}, {
id: 1,
name: 'Tyrion Lannister'
}, {
id: 2,
name: 'Morgan Dexter'
}, {
id: 3,
name: 'Lannister'
}, {
id: 4,
name: 'Silicon Vally'
}]
}),
displayField: 'name',
/*
If you use using this then initially you will see {0 values selected}
displayTpl: new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}'),
*/
valueField: 'id',
queryMode: 'local',
multiSelect: true,
filterPickList: true,
listeners: {
render: function (combo) {
//Use propery {displayTpl}
//The template to be used to display selected records inside the text field. An array of the selected records' data will be passed to the template.
combo.displayTpl = new Ext.XTemplate('{[values instanceof Array ? values.length === 1 ? values[0]["' + combo.displayField + '"] : values.length + " values selected" : values]}');
/*
you can also use like below function
combo.displayTpl = new Ext.XTemplate('{[this.getDisplayField(values)]}', {
getDisplayField: function (values) {
if (Ext.isArray(values)) {
var len = values.length;
return len == 1 ? values[0].name : (len + ' values selected');
}
return values;
}
});*/
}
}
}]
});
ありがとうございました。私はまた、過去のフィドルの例を使用しようとしましたが、何らかの理由でそれは当時は機能しませんでした。 – TobsenB
は大歓迎です@ TobsenB :)。あなたが逃したことがあるかもしれません。 –