Question

I have a CellList in GWT, i need to deselect the cell when one link is clicked without using the selectionchange handler.Can someone help in this situation.

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)

            }
        });

}

Thanks in advance,

Raj

Was it helpful?

Solution

Using a SingleSelectionModel, is as easy as:

lLink.addClickHandler(new ClickHandler() {
  @Override
  public void onClick(ClickEvent pEvent) {
    MyClass selected = lSelectionModel.getSelectedObject();
    if (selected != null) {
      lSelectionModel.setSelected(selected, false); 
    }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top