GXT EditorGrid: choose cell editor type on a cell by cell basis

心不动则不痛 提交于 2019-12-06 14:31:05

问题


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.


回答1:


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);

}


来源:https://stackoverflow.com/questions/6973189/gxt-editorgrid-choose-cell-editor-type-on-a-cell-by-cell-basis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!