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

本秂侑毒 提交于 2019-12-04 20:23:23

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

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