2

我在 GWT 中有一个 CellList,我需要在不使用 selectionchange 处理程序的情况下单击一个链接时取消选择单元格。在这种情况下有人可以帮忙吗?

CellList<MyClass> cellList;    
SingleSelectionModel<MyClass> lSelectionModel;

final SingleSelectionModel<MyClass> lSelectionModel = 
    new SingleSelectionModel<MyClass>();
this.cellList.setSelectionModel(lSelectionModel);

public void setSelected(final MyClass pClass) {

        Anchor lLink = new Anchor();
        lLink.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent pEvent) {
        //Here i need to deselect the cell(Myclass)

            }
        });

}

提前致谢,

拉吉

4

1 回答 1

1

使用SingleSelectionModel, 就像这样简单:

lLink.addClickHandler(new ClickHandler() {
  @Override
  public void onClick(ClickEvent pEvent) {
    MyClass selected = lSelectionModel.getSelectedObject();
    if (selected != null) {
      lSelectionModel.setSelected(selected, false); 
    }
});
于 2013-04-04T12:15:47.067 回答