您在这里有几个选择。但首先要确定为什么首先需要在网格中使用组合框。你需要
1) 一个标准的单元格编辑器插件,当您在单元格内单击时会被激活,或者
2)您是否需要在每一行中始终激活组合框来呈现您的单元格?
如果您的答案是 1),那么您需要做 2 件事: a) 覆盖默认的 CellEditing 插件以允许在每一行上使用不同的组合框。默认实现每列缓存一次编辑器配置。b) 提供一个在为您的单元格调用 getEditor() 时返回编辑器配置的函数。
我将在下面提供这些代码。
如果您对原始问题回答 2),那么您需要一个自定义组件,该组件将在您的单元格中呈现一个组合框。这样的野兽有两种实现,我使用的一种是 Skirtles http://skirtlesden.com/ux/component-column,另一种称为它的列组件
http://www.sencha.com/forum/showthread.php ?174504-Its.grid.column.Component
附录:
选项 1) 的代码
列配置 -
{ text: 'My Combo Column',
datIndex: 'someStoreField',
getEditor:function(record){
console.log('in get editor');
return myFunctionToDetermineEditorConfig(record);
}
}
单元格编辑器覆盖。'this' 是对 Grid 的引用
this.plugins = [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit:1,
//override original to allow for multiple editors in a column
getEditor:function (record, column) {
var editor = column.getEditor(record);
if (!editor) {
return false;
}
if (!(editor instanceof Ext.grid.CellEditor)) {
editor = new Ext.grid.CellEditor({
//editorId:editorId,
field:editor,
ownerCt:this.grid
});
} else {
editor.ownerCt = this.grid;
}
editor.editingPlugin = this;
editor.isForTree = this.grid.isTree;
editor.on({
scope:this,
specialkey:this.onSpecialKey,
complete:this.onEditComplete,
canceledit:this.cancelEdit
});
return editor;
}
})
];