好的,下面是如何在 Sencha EXTJS 中使用组合框的完整示例:
var grid = Ext.create('Ext.grid.Panel', {
store: store,
columns: [{
xtype: 'gridcolumn',
text: 'UserStatus',
dataIndex: 'userstatus',
editor: {
xtype: 'combobox',
allowBlank: false,
displayField: 'Name',
valueField: 'Id',
queryMode: 'local',
store: this.getStatusChoicesStore()
}
}],
width: 450,
renderTo: Ext.getElementById('hede')
});
现在 this.getStatusChoicesStore() 函数将为我们提供此组合框的选择(您可以在任何地方定义该函数,或者只是将其内联到列定义中,对我来说它更容易如果我为它创建一个函数来阅读):
getStatusChoicesStore: function() {
return Ext.create('Ext.data.Store', {
data: [{
Id: 0,
Name: "Active"
}, {
Id: 1,
Name: "Inactive"
}]
});
},
此外,可以在here 找到更多信息和示例。