GXT网格行不可选 [英] GXT Grid row is not selectable

查看:116
本文介绍了GXT网格行不可选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是GWT新手。我有一个网格,它具有从BaseModel映射的简单数据。当用户选择一行时,它应该被选中。我已经检查了几个例子并发布,似乎我们正在做的正确。下面的代码来创建网格。



您可以提一下这个选择会被阻止的senarios吗?

  List< BaseModel> gridData = new ArrayList< BaseModel>(); 
列表< ColumnConfig> config = new ArrayList< ColumnConfig>();
config.add(新的ColumnConfig(isPrimary,Primary,70));
config.add(新的ColumnConfig(accountName,Account Name,320));
config.add(新的ColumnConfig(activeProgram,Active Program,150));
config.add(新的ColumnConfig(accountNumber,Account,100));
config.add(新的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(Horizo​​ntalAlignment.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);
返回cp;


解决方案

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

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



.x-grid3-row-over类在几个位置声明,这有助于定义网格的行颜色。我已经删除了背景图像和颜色属性,它开始工作,因为它应该工作。所有这一次,当我将鼠标悬停时,背景图像正在显示。

I'm new to GWT. I've a grid which has simple data mapped from a BaseModel. When the user selects a row, it is supposed to be selected. I've checked a few examples and post, it seems that we are doing it correctly. Code below to create the grid.

Could you please mention the senarios in which this selection will be blocked?

    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;

解决方案

It was not even the answer which i gave previously, it is the CSS!!!!!

I'm using GXT lib for the GWT , they have gxt-all.css file and in this file ,they have

.x-grid3-row-over class declared at a couple of places, this helps to define the row color of the grid. I've removed the background image and the color properties in there, it started working as it is supposed to work. All this time, the background image is being shown when I mouse over.

这篇关于GXT网格行不可选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆