我正在使用GWT 2.5 CellTable,我想编写Onclick事件(单击)以执行某些操作,我在单击CellTable行时无法获得正确的行索引,只有双击事件才能正确返回行。
这是我的代码,
cellTable.addDomHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
CellTable<List<String>> selectedcell = (CellTable<List<String>>) event.getSource();
System.out.println(" Current Selected Row : "+selectedcell.getKeyboardSelectedRow());
}
}, ClickEvent.getType());
答案 0 :(得分:0)
我认为您忘记了下载点击事件
cellTable.addDomHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
// TODO Auto-generated method stub
CellTable<ContactInfo> selectedcell = (CellTable<ContactInfo>) event.getSource();
System.out.println(" Current Selected Row : "+selectedcell.getKeyboardSelectedRow());
}
}, ClickEvent.getType());
cellTable.sinkEvents(Event.ONCLICK);
答案 1 :(得分:0)
也许我错了,但你可以试试selection model
的东西:
http://www.gwtproject.org/javadoc/latest/com/google/gwt/user/cellview/client/AbstractHasData.html#getSelectionModel()
GetKeyboardSelected表示由...键盘...: - )
选择