我正在使用ExtJS 4.2,当我在store
中打印loadComboBox()
时,项目存在,但它们不会出现在下拉列表中。下拉列表是空的。
Ext.define('ReportFieldModel', {
extend: 'Ext.data.Model',
fields: [{
'name': 'name',
'type': 'string'
}]
});
Ext.define('ReportFieldComboStore', {
extend: 'Ext.data.JsonStore',
model: 'ReportFieldModel'
});
var config = {
'type': "Summary",
'columns': [
"red",
"yellow",
"orange",
"green",
"blue",
"indigo",
"violet"]
};
function processItem(item) {
return Ext.create('ReportFieldModel', {
name: item
});
}
function processItems(data) {
var arr = [];
if (data && data.length > 0) {
for (var i = 0; i < data.length; i++) {
arr.push(processItem(data[i]));
}
}
return arr;
}
function loadComboBox(combo, data) {
var store = combo.store;
var columns = data.columns;
var processed = processItems(columns);
console.log(JSON.stringify(processed, undefined, 2));
store.loadData(processed, false);
}
Ext.onReady(function () {
var resultsPanel = Ext.create('Ext.panel.Panel', {
title: 'Results',
width: 200,
height: 400,
renderTo: Ext.getBody(),
layout: {
type: 'vbox',
align: 'stretch',
padding: 5
},
items: [{
xtype: 'combo',
itemId: 'myCombo',
displayField: 'name',
valueField: 'name',
mode: 'local',
store: Ext.getStore('ReportFieldComboStore')
}]
});
loadComboBox(resultsPanel.down('#myCombo'), config);
});
答案 0 :(得分:3)
配置为queryMode
,而不是mode
。