[英]GXT Grid row is not selectable
我是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;
我不知道它為什么起作用,但是在對網格對象設置了所有屬性之后,我已經在函數本身內部進行了網格聲明和實例化,然后將其分配給了成員變量。 這沒有任何問題。 請參見下面的代碼段。
**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;
這甚至不是我之前給出的答案,而是CSS !!!!
我為GWT使用GXT庫,它們有gxt-all.css文件,在此文件中,
在幾個地方聲明了.x-grid3-row-over類,這有助於定義網格的行顏色。 我已經刪除了其中的背景圖像和顏色屬性,它開始按預期工作。 一直以來,當我將鼠標懸停在上方時,背景圖像都會顯示出來。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.