1

我是 GWT 的新手。我有一个网格,其中包含从 BaseModel 映射的简单数据。当用户选择一行时,它应该被选中。我检查了一些示例并发布,看来我们做得正确。下面的代码来创建网格。

您能否提及将阻止此选择的情景?

    List<BaseModel> gridData= new ArrayList<BaseModel>();
    List<ColumnConfig> config = new ArrayList<ColumnConfig>();
    config.add(new ColumnConfig("isPrimary","Primary",70));
    config.add(new ColumnConfig("accountName","Account Name",320));
    config.add(new ColumnConfig("activeProgram","Active Program",150));
    config.add(new ColumnConfig("accountNumber","Account",100));
    config.add(new ColumnConfig("accountXref","Account Xref",150));
    config.add(new ColumnConfig("status","Status",93));

    ColumnModel cm = new ColumnModel(config);

    PagingModelMemoryProxy proxy = new PagingModelMemoryProxy(gridData);
    final PagingLoader<PagingLoadResult<Data>> loader = new BasePagingLoader<PagingLoadResult<Data>>(proxy);

    loader.setRemoteSort(false);
    store = new GroupingStore<Data>(loader);
    final PagingToolBar toolBar = new PagingToolBar(10);
    toolBar.bind(loader);
    loader.load(0, 10);

    GroupingView view = new GroupingView();
    view.setShowGroupedColumn(true);
    view.setForceFit(true);
    view.setGroupRenderer(new GridGroupRenderer() {
        public String render(GroupColumnData data) {
            String l = data.models.size() == 1 ? "Item" : "Items";
            return data.group.substring(data.group.indexOf("|") + 1, data.group.length())
                    + " (" + data.models.size() + " " + l + ")";
        }
    });

    ContentPanel cp = new ContentPanel();
    cp.setBodyBorder(false);

    cp.setButtonAlign(HorizontalAlignment.CENTER);
    cp.setLayout(new FitLayout());
    cp.setFrame(true);
    cp.setSize(verticalPanelWidth, "300px");
    cp.setBorders(hidden);
    cp.setBottomComponent(toolBar);
    GWT.log("store size" + store.getCount());
    grid = new Grid<Data>(store,cm);
    final GridSelectionModel<Data> sm = grid.getSelectionModel();
    sm.setSelectionMode(SelectionMode.SINGLE);
    grid.setSelectionModel(sm);

    final CellSelectionModel<Data> csm = new CellSelectionModel<Data>();
    csm.bindGrid(grid);

    grid.setBorders(true);
    grid.ensureDebugId("gridDebugId");
    //grid.ensureDebugId("gridDebugId");
    grid.setTabIndex(5);
    cp.add(grid);
    return cp;
4

2 回答 2

0

我不知道它为什么起作用,但我已经在函数本身内部进行了网格声明和实例化,在设置网格对象上的所有属性后,我已将其分配给成员变量。这没有任何问题。请参见下面的代码片段。

**Grid<Data> grid = new Grid<Data>(store,cm);**
final GridSelectionModel<Data> sm = grid.getSelectionModel();
sm.setSelectionMode(SelectionMode.SINGLE);
grid.setSelectionModel(sm);

final CellSelectionModel<Data> csm = new CellSelectionModel<Data>();
csm.bindGrid(grid);

grid.setBorders(true);
grid.ensureDebugId("gridDebugId");
//grid.ensureDebugId("gridDebugId");
grid.setTabIndex(5);
**globalGrid = grid;**
cp.add(grid);
return cp;
于 2013-08-22T18:18:38.637 回答
0

这甚至不是我之前给出的答案,它是 CSS !!!!!!

我正在为 GWT 使用 GXT lib,他们有 gxt-all.css 文件,在这个文件中,他们有

.x-grid3-row-over 类在几个地方声明,这有助于定义网格的行颜色。我已经删除了那里的背景图像和颜色属性,它开始按预期工作。一直以来,当我将鼠标悬停时,都会显示背景图像。

于 2013-10-18T18:02:03.470 回答