问题描述
GXT EditorGrid提供了一种机制来设置列的编辑器类型。
有没有在单元格的基础上定义编辑器类型? p>
对于好奇心:
我需要创建一个转置的表;列成为行,行是列。在这种情况下,列(从普通表的角度)将具有各种编辑器类型,由此一行将具有相同的编辑器类型。
基本上,你必须处理BeforeEdit事件并设置编辑器。这是一个可以从中实现网格的基类:
public abstract class AnyEditorGrid< T extends ModelData>扩展EditorGrid< T> {
public AnyEditorGrid(final ListStore< T> listStore,final ColumnModel columnModel){
super(listStore,columnModel);
addListener(Events.BeforeEdit,new Listener< GridEvent< T>(){
@Override
public void handleEvent(final GridEvent< T> be){
final CellEditor编辑器= getEditor(be.getRowIndex(),be.getColIndex(),be.getModel());
if(editor!= null){
getColumnModel()setEditor(be.getColIndex ,编辑);
} else {
be.setCancelled(true);
}
}
});
}
保护抽象CellEditor getEditor(int rowIndex,int colIndex,T model);
}
GXT EditorGrid provide a mechanism to set a type of editor for a column.
Is there anyway to define the editor type on a cell by cell basis?
For the curious minds:
I need to create a transposed table; the column become the row and the row is the column. That being the case, a column (from a normal table point of view) will have various editor type, whereby a row will have identical editor type.
basically, you have to handle the BeforeEdit event and set the editor. Here is a base class from which you can implement your grid:
public abstract class AnyEditorGrid<T extends ModelData> extends EditorGrid<T> {
public AnyEditorGrid(final ListStore<T> listStore, final ColumnModel columnModel) {
super(listStore, columnModel);
addListener(Events.BeforeEdit, new Listener<GridEvent<T>>() {
@Override
public void handleEvent(final GridEvent<T> be) {
final CellEditor editor = getEditor(be.getRowIndex(), be.getColIndex(), be.getModel());
if (editor != null) {
getColumnModel().setEditor(be.getColIndex(), editor);
} else {
be.setCancelled(true);
}
}
});
}
protected abstract CellEditor getEditor(int rowIndex, int colIndex, T model);
}
这篇关于GXT EditorGrid:逐单元格选择单元编辑器类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!