开发者

Can't get Row Click Handler for GWT CellTable

开发者 https://www.devze.com 2023-03-04 13:15 出处:网络
I\'m trying to setup a Row-click handler for the GWT CellTable (GWT 2.1). The stackoverflow post here indicates that you should be able to get the type of handler using:

I'm trying to setup a Row-click handler for the GWT CellTable (GWT 2.1). The stackoverflow post here indicates that you should be able to get the type of handler using:

boolean isClick = "click".equals(event.getType()) 

But event.getType() doesn't return a string, so the evaluation isn't working. The CellPreviewEvent is working, but it fires lots of events (no开发者_JAVA技巧t just click), and I'm having a hard time figuring out how to only get the click events..

Has anyone found a solution to this? (Or can explain what I'm doing wrong in following the post)


You need to get the native event associated with the GwtEvent:

"click".equals(event.getNativeEvent().getType());


Use a NoSelectionModel and listen to SelectionChange events.


I'm using a check column with a celltable. You can handle selection change event like the sample below.

selectionModel.addSelectionChangeHandler(new Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
    Contentshort objSelected = selectionModel.getSelectedObject();
if (selectionModel.isSelected(objSelected)) {
    Window.alert("selected");
} else {
    Window.alert("deselected");
}               
}       
});
0

精彩评论

暂无评论...
验证码 换一张
取 消