我是 Ext JS 的新手。在这里,我正在尝试使用 Store 填充 ComboBox。我可以看到呈现的组合框,但没有下拉值。有人可以查看并告诉我下面的代码有什么问题。
app.js:-
Ext.Loader.setConfig({
enabled: true
});
Ext.application({
name: 'MVCCombo',
controllers: ['Skills'],
autoCreateViewport: true
});
控制器(Skills.js):-
Ext.define('MVCCombo.controller.Skills', {
extend : 'Ext.app.Controller',
//define the stores
stores : ['Skills'],
//define the models
models : ['Skill'],
//define the views
views : ['combo.Skill'],
init: function() {
alert("Controller Invoked");
}
});
商店(Skills.js):-
Ext.define('MVCCombo.store.Skills', {
extend:'Ext.data.Store',
model:'MVCCombo.model.Skill',
data: [{
"id": "1",
"name": "Java"
}, {
"id": "2",
"name": "J2EE"
}, {
"id": "3",
"name": "Ext JS"
}
]
});
型号:(Skill.js):-
Ext.define('MVCCombo.model.Skill', {
extend: 'Ext.data.Model',
fields: [{name:'id', type:'string'},{name:'name', type:'string'}]
});
查看(ViewPort.js):-
Ext.define('MVCCombo.view.Viewport', {
extend: 'Ext.Viewport',
layout: 'fit',
requires: [
'MVCCombo.view.combo.Skill'
],
initComponent: function() {
var me = this;
Ext.apply(me, {
items: [
{
xtype: 'cmbBox'
}
]
});
me.callParent(arguments);
}
});
查看(Skill.js):-
Ext.define('MVCCombo.view.combo.Skill' ,{
extend: 'Ext.form.ComboBox',
alias : 'widget.cmbBox',
allowBlank: false,
queryMode: 'local',
valueField: 'id',
displayField: 'name',
store: 'Skills'
});